matthias_k
July 27th, 2003, 01:00 PM
Hey there,
The weird problems strike back once again :)
This time I want to catch a WM_CLOSE message each time the user wants to exit the program, in order to display a message box asking the user if he really wants to exit. If he clicks YES, a WM_QUIT message is sent. If NO, I return from the message handler.
The problem is... the message box shows up, but it takes waaay longer than it should. If I hit escape to tell the app I want to exit, it takes like 5 seconds until the message box finally appears. During this time the app seems to freez, I can't even maximize/minimize it or do some other default operation.
Here's the code of my window's message handler:
LRESULT CApplication::WindowProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
{
switch( nMsg )
{
case WM_COMMAND:
break;
case WM_KEYDOWN:
switch( LOWORD( wParam ) )
{
case VK_ESCAPE:
PostMessage( hWnd, WM_CLOSE, wParam, lParam );
break;
default:
break;
}
break;
case WM_PAINT:
break;
case WM_CLOSE:
if( MessageBox( hWnd, "Really want to quit?", "Exit program", MB_YESNO|MB_ICONQUESTION ) == IDYES )
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, nMsg, wParam, lParam );
}
return 0L;
}
This method is called from the global CALLBACK message handler.
Any ideas?
The weird problems strike back once again :)
This time I want to catch a WM_CLOSE message each time the user wants to exit the program, in order to display a message box asking the user if he really wants to exit. If he clicks YES, a WM_QUIT message is sent. If NO, I return from the message handler.
The problem is... the message box shows up, but it takes waaay longer than it should. If I hit escape to tell the app I want to exit, it takes like 5 seconds until the message box finally appears. During this time the app seems to freez, I can't even maximize/minimize it or do some other default operation.
Here's the code of my window's message handler:
LRESULT CApplication::WindowProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
{
switch( nMsg )
{
case WM_COMMAND:
break;
case WM_KEYDOWN:
switch( LOWORD( wParam ) )
{
case VK_ESCAPE:
PostMessage( hWnd, WM_CLOSE, wParam, lParam );
break;
default:
break;
}
break;
case WM_PAINT:
break;
case WM_CLOSE:
if( MessageBox( hWnd, "Really want to quit?", "Exit program", MB_YESNO|MB_ICONQUESTION ) == IDYES )
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, nMsg, wParam, lParam );
}
return 0L;
}
This method is called from the global CALLBACK message handler.
Any ideas?