MessageBox, Vista, and WM_PAINT

Hi -

Has anyone else noticed this? In Vista, there are times when using win32 MessageBox() that the message box is not displayed topmost, which should be automatic. Heck, I can't even get it to work correctly using the MB_TOPMOST or modal styles.

Anyway, I have traced the error down to the handling of the WM_PAINT message. The funny thing is, I don't even have to do a single thing when handling the message. For example, if I just do this:

1
2
3
4
5
6
7
8
9

case WM_PAINT:
break;


case WM_LBUTTONDOWN:
     MessageBox(hwnd,"TEST","",MB_OK);
break;


... then all of a sudden the message box fails to come to the forefront. I press "Alt" and it shows up, I click "OK" and everything goes back to normal.

I do this, and the problem goes away:

1
2
3
4
5
6
7
8
9

/*case WM_PAINT:
break;*/


case WM_LBUTTONDOWN:
     MessageBox(hwnd,"TEST","",MB_OK);
break;


This has never happened to me in XP. I can literally compile and run the same code in Dev-C++ on both operating systems, yet only Vista exhibits this behavior. Does anyone know why this occurs? Thanks in advance... maybe I'm missing something obvious here?
I have barely any experience using win32 stuff but I can clearly remember reading the order of messages? (the cases) "rarely" matters, maybe this is one of those situations?
Good suggestion. Unfortunately, it didn't work when I tried varying the order of operations. Man is this is ever confusing...
Last edited on
Topic archived. No new replies allowed.