-
MessageBox API
As I mentioned in an earlier post, I'm using the MessageBox API call to display a message before running a console application.
Unfortunately, this acts as a "modal" form within my application. In other words, I can freely access other Windows, but my console application will not continue execution until the message box is closed.
I tried to set the hWnd parameter to NULL and HWND_DESKTOP, but neither changes the behavior. Is there a way to keep the MessageBox on the desktop and allow my program to continue execution? Do I need to use a different API call?
Any help would be greatly appreciated..
-
MBAPPLMODAL - message box application modal is the default behavior. You need to use another kind of dialog box.
-
-
-
Create your own dialog template and dialog proc and use CreateDialog.
You must extend your message loop then:
Code:
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
if(!IsDlgMessage(hdlg, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
hdlg is the handle returned by CreateDialog.
-
How about starting a new thread? That should allow the program to continue. Note that if the program finishes, the message box will automagically be closed.
-
Good idea. Like
Code:
DWORD MBThreadMain(LPVOID pVoid)
{
MessageBox(NULL, "Hello", "Hello", MB_OK);
return 0;
}
If you at one point want to stop until the messagebox is closed, use WaitForSingleObject