static control not being created

Hello,

In the WM_CREATE case of my main window wndproc I am trying to create a static control. It fails to create, producing the message box specificed in the if statement. I do not know why! Any advice? The code is as follows:

case WM_CREATE:
{
HWND hSt1= CreateWindowEx(
WS_EX_CLIENTEDGE,
_T("STATIC"),
_T(" "),
SS_LEFT,
30, 30, 100, 100,
hwnd,(HMENU)IDC_STATIC1, GetModuleHandle(NULL), NULL);

if(hSt1 == NULL){MessageBox(hwnd, _T("Could not create static control."), _T("Error"), MB_OK | MB_ICONERROR);}

Have you provided enough information to the CreateWindowEx function.
Try adding the WS_CHILD and WS_VISIBLE styles:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
case WM_CREATE:
{
    HWND hSt1= CreateWindowEx(
    WS_EX_CLIENTEDGE,
    _T("STATIC"),
    _T(" "),
    SS_LEFT|WS_CHILD|WS_VISIBLE,
    30, 30, 100, 100,
    hwnd,
    (HMENU)IDC_STATIC1, 
    GetModuleHandle(NULL),
     NULL);

if(hSt1 == NULL){MessageBox(hwnd, _T("Could not create static control."), _T("Error"), MB_OK | MB_ICONERROR);}
Thanks so much - that had been annoying me for hours!
Topic archived. No new replies allowed.