Re: [Dev-C++] strings for win32 (ABOUT UNICODE)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Giuseppe F. <egi...@ti...> - 2001-09-17 12:58:03
|
----- Original Message -----=20
From: Tomas Dolejsi=20
To: dev...@li...=20
Sent: Saturday, September 15, 2001 7:44 PM
Subject: RE: [Dev-C++] strings for win32 (ABOUT UNICODE)
Hi Guiseppe!
I learned a little about unicode and Win32 API. Let me share this with =
you.
Win32 contains both ASCII and wide char modifications of functions =
that require text parameter(s).
e.g.
There's no entry point in the USER32.DLL for the function called =
MessageBox.
Instead, there are two others. MessageBoxA (for ascii) and MessageBoxW =
(for wide chars).
But you don't need to worry about it.
Simply use MessageBox function.
How all this works?
The real functions are defined in WinUser.h exactly that:
int WINAPI MessageBoxA (WHND hWnd, LPCSTR lpText, LPCSTR lpCaption, =
UINT uType) ;
int WINAPI MessageBoxW (WHND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, =
UINT uType) ;
Beside this definitions, you'll find there following code:
#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif
It means that if you the call MessageBox function the MessageBoxA =
function will be called,
unless you insert this line
#define UNICODE
in the beginning of your own code.
It is the same with other text based functions (TextOut, sprintf, =
fprintf, strlen, strstr, atc.)
There's a pice of my code I work on
MessageBox(hWnd, "Furcadia Character Description Editor\nCopyright =
=A9 2001 Tomas Dolejsi\nVersion 1.01 (Freeware)\n\nCompiled with DevC++ =
4 ", "Fcde", MB_OK);
If you want to use the UNICODE (wide char) instead of ASCII, adding =
the line #define UNICODE is one thing. You also need to convert all text =
(and char) constants you give the functions as the parameters. The =
converison is carried out with L key (e.g. wchar_t * pw =3D L"Hello!" =
.) Type wchar_t is unsigned short. There's a macro TEXT() which =
converts the given text if UNICODE directive is defined.=20
TEXT() macro is defined in WinNT.h:=20
#ifdef UNICODE
#define TEXT(q) L##q
#else
#define TEXT(q) q
#endif
That's all from me. I also attach a simple dialog example (originaly =
from Ch. Petzold's Programing Windows).
Best luck!
Hi Tomas. The code compile in my computer too.=20
Thanks for your help.=20
Giuseppe
|