|
You'll be the first person to get a copy. I've set up everything how you said, except I had to set it to a color depth of 32 instead of 24 (what my system is running). Which raises the question- what's the best way to detect what the systems color depth is, so that a person with different settings isn't SOL?
Here is how I set up everything...
CGameWin::CGameWin() : CGameKeyBindingDialog("CKeyboardDialog")
{
Create(NULL, "Tic-Tac-Toe", WS_OVERLAPPEDWINDOW,
rectDefault, NULL, "Game");
CGameKeyBindingDialog.setMainWnd(this);
OffSetX, OffSetY = 0;
CBitGrid.CreateBitmap(150, 150, 1, 32, NULL);
grid_DC.CreateCompatibleDC(NULL);
grid_DC.SelectObject(CBitGrid);
buffer_DC.CreateCompatibleDC(&grid_DC);
xo_DC.CreateCompatibleDC(&grid_DC);
CBitXO.CreateCompatibleBitmap(&grid_DC, 100, 100);
CBitBackBuffer.CreateCompatibleBitmap(&grid_DC, 400, 400);
InitBrushPen();
DrawBackground();
}
|
|
|
|
|
CoffeeAddict19 wrote: what's the best way to detect what the systems color depth is
One way is:
CDC dc;
dc.CreateCompatibleDC(0);
int BitsPerPixel = dc.GetDeviceCaps(PLANES) * dc.GetDeviceCaps(BITSPIXEL);
Note that you have access to both the number of planes and the bits per pixel individually,
which is just what you need when creating the bitmaps.
That being said, if you use the CreateCompatible___ methods then that's done for you.
Thus
CBitGrid.CreateBitmap(150, 150, 1, 32, NULL);
grid_DC.CreateCompatibleDC(NULL);
can be
grid_DC.CreateCompatibleDC(NULL);
CBitGrid.CreateCompatibleBitmap(&grid_DC, 150, 150);
|
|
|
|
|
Hi there!
I have a COM dll built in VC++ 6.0, and I use it in a Web application written in VB.NET. I'm having some strange problems, throuing some exceptions and other things...
I suspect the COM dll, but I just can't figure why. If I use it from a regular windows application it seems to work fine, no problems.
So, I was think if there is a way to debug into the COM from the WEB app I could see some more things. Does any one knows how to do it, or have any suggestion for my problem?
Thanks for you time.
ALMC
|
|
|
|
|
Is it crashing during initialization itself? or while calling a particular method?
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
Hi!
It seems that is crashing after some users log into the web application... For what I can see the COM isn't detroyed everytime after the release of the object (we have implemented a cicle forcing the com to be released and even so...)
I hope it helps.
ALMC
|
|
|
|
|
Hello,
I have been using code project for a long time, and I always found classes, code snippets according to my needs. First of all thank you all
I have a project based on CDatabase and CRecordSet (the class I'm using is this: CODBCAccess http://www.codeproject.com/database/codbcaccess.asp). A lot of coding had been done on my project.
Because of language character problems I changed my project to UNICODE. Then my problems started. I had to change every occurance for char * and CString conversions.
But I am really stuck with this database issues. CDatabase automatically converts the query strings to an ansi version so I can not insert UNICODE strings to database. And because of it is a core library I can do nothing about it.
But CDaoDatabase supports UNICODE queries. So I want to change my project such a way that it will use CDaoDatabase. But as I said before it is a looong way to convert all database operations in my code. So I am considering to write a new class that acts like CODBCAccess class (I mean it's interfaces are same).
The thing I am asking is can you suggest a better way to do this? Or are there any already implemented classes for this purpose?
I hope I am clear. Sorry for my poor English. Please don't hesitate to ask questions to clarify my situations if I am not clear enough.
Thank you for you answers
|
|
|
|
|
CDatabase supports Unicode queries. Where are you having problems after converting to Unicode?
|
|
|
|
|
the code is something like this:
CDatabase myDatabase;
CString sSQL = "insert statement that contains UNICODE characters like çöşiğü";
myDatabase.ExecuteSQL(sSQL);
When I trace into ExecuteSQL() there I find this (in file vc98\mfc\src\dbcore.cpp):
<br />
AFX_ODBC_CALL(::SQLExecDirect(hstmt, (UCHAR*)T2A((LPTSTR)lpszSQL), SQL_NTS));<br />
As you can see the wide string I passed as a parameter is converted to ansi using T2A().
Since this is a core library, I cannot change it. Or am I thinking wrong?
Thanks for your interests.
|
|
|
|
|
Here I am, lame again.
Hello everybody, I have another question. And this time I think I won't be able to answer it my self.
I want to know how to play the raw data from an audio stream (opened with AVIFileGetStream). I searched for a solution, but couldn't find any.
I read that I can play the audio data using DirectSound or some Win32 functions. I don't want to use DirectSound (yet). So that leaves those Win32 functions. Can anyone tell me what are these functions I should use? And there's another thing - what if the data is compressed. Do I have to decompress it and how should I do that?
Please help
These smileys... I like them .
|
|
|
|
|
Hi,
I wrote a DLL,for serial port communication.When i open the port i have created a thread in suspended mode,even created Events in same function later on i have resumed the thread,i wrote callback function.This callback function is called ,when ever the recevie event is set,when ever i get data from the instrument.Then i read the data send it to client application through Firefunction,i.e by connection points.I have three commands CMDONE,CMDTWO and CMTHREE.I have set a BOOL variable blntwo=FALSE;if( blntwo==TRUE),i will read the data using callbackfuntion,if not i will return from the function ,even if the control comes into it.
First i send CMDONE i get "OK" reply back from instrument.For this i wrote the data onto the port and read "OK" directly instead of using serailback function.
Then i will send CMDTWO,here i just write the data on the port and set blntwo=TRUE;.I will be getting data constantly from instrument,i will read this data using callback function ,then send this data to client application through Fire function.
Then i will send CMDTHREE,i am setting blntow=FALSE,here i want to suspend the thread,so that reading is not done by Serialcall function,Instead i want to read the data directly here when i send CMDTHREE.But this is not happening..May be bec of synchronization problem..how to solve it..?If i don`t suspend the thread application is crashing..
Thanks in before
James
|
|
|
|
|
Without code it's tough to know what's going on. I'd be worried about suspending the thread
from another thread because you don't know where the thread is going to stop.
Again, I don't know your code, but maybe a notifying the thread (through a simple bool flag even)
to ignore data until a reply from CMDTHREE is received or something along those lines.
If the thread is receiving event-driven data and you suspend it then how do you know you're in
a correct state to read data directly?
|
|
|
|
|
Hi,
Thanks for the reply,as u have asked for the code,i have downloaded a project from codeproject
http://www.codeproject.com/com/CompCateg2.asp[^]
In this i am using only serialport communication module,to existing code i have added my three functions CMDONE,CMDTWO,CMDTHREE,and if(blnTwo==TRUE) in serial callback function.please ask me any more information is required,bec i have to fix this problem.
Thanks in before
James
|
|
|
|
|
RockyJames wrote: i have downloaded a project from codeproject
You can ask Mr. Zak Howland (the author) yourself. There's a place for messages at the bottom
of the article.
Mark
|
|
|
|
|
I have a program that uses at least 50 calls to the CString::Format function. The problem comes when I change from Debug to Release mode and try to compile. In Release mode, the function expects a 'const wchar_t *' and in Debug a 'const char *'. I know that you can use the 'L' macro to make a literal string a 'const wchar_t *', but then it doesn't work when I switch back to Debug.
Is there a way to get around this or do I just have to save my release compilation until the very end and add the 'L' macro to all of these functions? Also, does anybody know the reason Microsoft did this?
Thanks,
Dustin
|
|
|
|
|
Could it be that the release build is unicode, and debug build isn't?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Good call. That fixed it. I didn't even think about checking that. You're the man.
|
|
|
|
|
Thanks.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Debug vs Release or Debug vs RELEASE UNICODE?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I love this board. 2 helpful answers in under 10 minutes.
|
|
|
|
|
For all string literals in your code, you should use the _T("xxx") macro.
For unicode builds, _T() is replaced by 'L', whereas for non-unicode builds it gets replaced by white space. So, literals end up correctly defined automatically, regardless of the build.
Mike
|
|
|
|
|
|
This is a shamed question of VC++ and MFC newbee.
I have Dialog box with it's CDialog derived class, which contains some controls and especially edit controls. The variables controls are int type.
When i input a value in the edit control and I close the dialog by pushing Ok buton, the value is lost when I open again the Dialog.
How can I prevent my data to be cleared?
many thnks for your help.
PS: sorry for my poor English, it is also newbee )
|
|
|
|
|
before you call DoModal on the dialog, set the member variables (the ones that are tied to the controls) to the values you want the controls to show.
99% of all the dialogs i've ever done end up being launched like this:
CMyDialog foo;
foo.m_intMember1 = someValue1;
foo.m_intMember2 = someValue2;
if (foo.DoModal()==IDOK)
{
someValue1 = foo.m_intMember1;
someValue2 = foo.m_intMember2;
}
|
|
|
|
|
Many thanks,
It works well.
|
|
|
|
|
Do you want to save these values for next time that you run your program ?
|
|
|
|