Hi, this is so weird, so I have no other option than asking for a little help again.
I have a button BUTTON2 created while WM_COMMAND (when I press a button created with WM_CREATE, called BUTTON1). When I click on the BUTTON2 a MessageBox element should appear, with a message. What happens is that when I click on it the window looses its focus but the message doesn't appear.
The structure of the messages handler is like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
WM_CREATE
//BUTTON1 is created here
break;
WM_COMMAND
if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)) {
switch(LOWORD(wParam)) {
case BUTTON1:
//Here I create BUTTON2
break;
case BUTTON2:
//Here I try to display a message. This doesn't show but the
//window is unfocused
MessageBox(NULL, "Hi", "Message", MB_OK|MB_ICONINFORMATION);
break;
}
}
break;
Can anyone give me a hand. I am lost again. Thank you!
The only thing I can think of is you got the parents screwed up somewhere. Like you gave BUTTON2 a null parent when you created it instead of giving it your window.
Yes, it was that. I used the hWnd argument of the messages handler in a wrong place. (I forgot that the hWnd argument is not always pointing to the main window). "And there was light"