1) Go into project properties and set the character set to 'unset' or Multi-byte; |
|
|
i am a beginner at windows programming . |
The Windows SDK uses TCHAR's instead of regular chars. It's a long story, but you should change your char's to TCHAR's, and enclose all string literals with _T() or TEXT(). This will handle the conversion to Unicode transparently. |
Now, does that mean I'm recommending that he skirt the whole wide character issue and use ansi permanently? No, it doesn't. |
However, if he follows the advice of Disch and WebJose, what he now has to face is the translation of the whole Forger's tutorial to wide character at a time when he is just learning the fundamentals of Windows Programming |
Whereas, if he follows my advice, he'll be able to paste the code from that Forger's tutorial right into Visual Studio, and it will just work 'as is'. |
webJose wrote: |
---|
Maybe Disch have created an article about that in the Articles section?? |
|
|
|
|
|
|
|
|
|
|
|
|
If UNICODE is defined (it is by default in recent versions of Visual Studio), the following three programs will work.... |
MessageBox(NULL,L"Here Is A Message!",L"Title",MB_OK);
MessageBox(NULL,_T("Here Is A Message!"),_T("Title"),MB_OK);
Whether or not UNICODE is defined should be immaterial to how you write your program. That's kind of the point. You should write your code so that it will work no matter how that is defined.... |
|
|
Well, by that line of reasoning it follows that one shouldn't even use the macros that allow for the generic use of the Windows functions, |
The 'L' prefix is I believe a part of the C/C++ languages, whereas I believe the macros in tchar.h aren't (Microsoft specific). |
So if you want your code to work irregardless of the definition of macros, that's where you end up. |
Much ado about nothing, fellas |
Give them that, as freddie1 did. |
I know a lot of seriously expert Windows programmers who still use Multi-byte as their character set, not just so MessageBox() will work, but for a number of other reasons as well, so to say that one should only use TCHAR when calling MessageBox() just doesn't jibe with some real experts who still call MessageBox() without using TCHAR or Unicode, but who simply override the necessity by setting their project to Multibyte. |
Telling to OP to use MessageBoxA() was certainly a reasonable answer. But so was freddie1's telling him to switch to multibyte. |
|
|
|
|
|
|
as well as having been published in peer reviewed literature as experts |