Weird behavior when pressing a button

I have WM_COMMAND with about 10 cases (10 buttons). Some of them create controls on the window or modify their content. They work fine. Other buttons are supposed to show messages when are clicked. It is so weird that when I click on these, not only the message doesn't appear but the window gets unfocused

1
2
3
4
5
6
7
8
9
10
11
12
case WM_COMMAND:                                                                                               
     if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)) {
          switch(LOWORD(wParam)) {
             case MYBUTTON:
                 MessageBox(NULL, "Hello", "Message", MB_OK|MB_ICONINFORMATION);
                 // Here, when I click on MYBUTTON, the message box doesn't 
                 // show up and the window becomes unfocused
             break;
             //Other buttons actions
          }
     }
}

The same occurs when instead of showing a message box I try to open another new window. In this case, when I close my actual window (the one that gets unfocused), the window that I try to open appears for a few moments (like a flash) and then closes (because when closing the main one the entire application is terminated). It's like it is created and opened but is shown only when the main one is closed. It's so strange. This didn't happen before. I don't know what code could have affected the behavior of the window. I have a lot of code. I hope somebody had the same problem sometimes and could know what does originate this. Maybe I should reprogram everything (about 1000 lines of code)
Thanks in advance
Last edited on
O.K. I made some changes and I found out that when creating the second window, the name of its class was the same as the name of the main window's class. Could that be? I am asking because, even if it works, I am not sure about it. Thanks
Last edited on
If you debug this properly u will seee where it goes wrong. I had this happen to me lots of times.
Rename your dialog box.
Topic archived. No new replies allowed.