Write wide-characters in a STATIC

I am trying to do this and I get some weird results. I create a STATIC control with CreateWindowEx but the text of the STATIC control is some rare characters.

When I do this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// define UNICODE and _UNICODE
#define LABEL_TEXT "This is my text"

HWND control = CreateWindowEx(
               WS_EX_TRANSPARENT,
               L"STATIC",
               (WCHAR*)LABEL_TEXT,
               WS_CHILD|WS_VISIBLE|ES_LEFT,
               0,
               0,
               100,
               20,
               Hwnd,
               NULL,
               Instance,
               NULL
               );


The STATIC control displays characters which I think mean undefined characters (rare rectangles).

If I do this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
HWND control = CreateWindowEx(
               WS_EX_TRANSPARENT,
               L"STATIC",
               L"This is my text",
               WS_CHILD|WS_VISIBLE|ES_LEFT,
               0,
               0,
               100,
               20,
               Hwnd,
               NULL,
               Instance,
               NULL
               );

I get the text correctly.

I don't understand what is wrong with the first case.
Last edited on
This

#define LABEL_TEXT "This is my text"

is not a wide string. Change it to

#define LABEL_TEXT L"This is my text"
Thanks!
Topic archived. No new replies allowed.