So I started DirectX programming, and I've learned to use PeekMessage instead of GetMessage, but for some reason the program keeps running in the background when I close it. I have searched the forums, but I couldn't find a working solution. Here's my code:
Message Loop:
Code:
ZeroMemory ( &Msg, sizeof ( MSG ) );
while ( Msg.message != WM_QUIT )
{
if ( PeekMessage ( &Msg, hWnd, 0, 0, PM_REMOVE ) )
{
TranslateMessage ( &Msg );
DispatchMessage ( &Msg );
}
else
{
// Rendering, etc.
}
}
Window Procedure:
Code:
LRESULT CALLBACK WndProc ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
switch ( Msg )
{
case WM_CLOSE:
DestroyWindow ( hWnd );
break;
case WM_DESTROY:
PostQuitMessage ( WM_QUIT );
break;
default:
return DefWindowProc ( hWnd, Msg, wParam, lParam );
}
return 0;
}
Thanks.