Create control while WM_COMMAND

Helo again

I have a window that has some elements on it created inside the WM_CREATE case. Everyting is OK.
Now, when I click on a button, all the elements must destroyed and new elements created. The first new element is a STATIC control with a text. It shows very well. Conditioned by some variables, a text control should be also created. It is created too but the problem is that its borders don't appear until I move a little bit the window (it's like when it is redrawn the new textbox appears as it should). The new elements are created inside the WM_COMMAND messagem, not WM_CREATE.

It is something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
WM_CREATE:
//Create a button MY_BUTTON and other controls
break;
WM_COMMAND:
if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)) {
    switch(LOWORD(wParam)) {
        case MY_BUTTON:    
            //Create a STATIC control, it is shown properly
            if (some condition) {
                //Change the text of the STATIC control, it works fine
            } else {
                // Create a TEXTBOX, it is created but the borders are not drawn
                // until I change the window position (move it by holding its    
                // border)
            }
        break;
    }   
break;


What am I missing? Must I create controls only inside the WM_CREATE or WM_PAINT cases? Thanks!
Last edited on
I had a similar problem getting a bitmap to update as the user scrolled around it while "zoomed" and found that this refreshed properly (I just called it once after a minimize,maximize, etc).

1
2
3
4
5
6
    void Refresh()
    {
      RECT ControlWindowRect;
      GetWindowRect(_hDlg,&ControlWindowRect);
      ::RedrawWindow(_hDlg,&ControlWindowRect,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN);
    }


EDIT: This refreshes the entire dialog, not just one control.
Last edited on
EVRIKA!
It works. Thanks man!
Topic archived. No new replies allowed.