>>But it looks like its not portable
Of course not -- its only for MS-Windows :)
Tutorial here
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
> PostQuitMessage;
Maybe if this were a function call, say
PostQuitMessage(0);
Perhaps posting actual error messages instead of "it doesn't work" would help as well.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
sorry, but I am affraid this damn code is from link you just gave me...
Is there any good book?
The code in that link is perfect -- billions of people (:eek: ) have used it.
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Finally, actual error messages.
What you have there is a UNICODE problem. VS2003 onwards defaults to using UNICODE for all strings, not ASCII.
Anytime you see functions ending in 'W' or references to 'WSTR', it's a good bet it's something to do with migrating from ASCII to UNICODE.
The fix is pretty easy.
In the project settings, there is a section for the "Preprocessor"
Part of that will be a list of defines which are constant through the whole project (say WIN32). One of those should be "UNICODE", which you should remove.
After you've done that, rebuild it and see what happens.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Perhaps it exists as a check box or something elsewhere in the project settings (in VS 2005)
When the /D "_UNICODE" have gone, then it should build 'as is'.
I should point out that the improved way is to start making your code UNICODE compatible .
Eg.
MessageBox(NULL, _T("Err"), _T("ERR"), MB_OK | MB_EXCLAMATION);
> if(hwnd = NULL)
Are you sure you copy/pasted, because this is yet another typo
= should be ==
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
You didn't say which version of VC++ compiler you are using. VC++ 6.0 and VC++ 2005 set UNICODE differently.
VC++ 2005: select menu Project --> Properties . Expand the Configuration Properties folder then select General category. Now on the right side see "Character Set" and change it to "Not Set".
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
It surely is UNICODE problem like Salem mentioned, search msdn.microsoft.com to find out how to write UNICODE compatible programs and what are the relevant project settings. You'll learn how to change your project settings AND how to change the code if you don't want it UNICODE compat..
From what I remember from my ancient times is you need to #define UNICODE 1 (but that seems to have already been done !)
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
From what I remember from my ancient times is you need to #define UNICODE 1 (but that seems to have already been done !)
Yup -- like me, you too are outdated and nearly obsolete. :)
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75