RECT reqRect;
reqRect.left = 0;
reqRect.top = 0;
reqRect.right = 1280;
reqRect.bottom = 1024;
AdjustWindowRect(&reqRect,WS_OVERLAPPEDWINDOW,FALSE);
int winWidth = reqRect.right - reqRect.left;
int winHeight = reqRect.bottom - reqRect.top;
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), LoadIcon (NULL, IDI_APPLICATION),
LoadCursor (NULL, IDC_ARROW), NULL, NULL,_T("D3D Test"),
NULL };
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow( _T("D3D Test"), _T("D3D Test"),
WS_OVERLAPPEDWINDOW, 10, 10, winWidth, winHeight,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
g_renderer.Initialize(hWnd,TRUE,TRUE);
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message != WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
g_renderer.ProcessFrame();
}
// Clean up everything and exit the app
g_renderer.Shutdown();
UnregisterClass( _T("D3D Tutorial 1"), wc.hInstance );
Win32 PeekMessage loop problem
So, I am using a typical win32 window and game loop:
Every so often I get an erroneous WM_QUIT message (such as when is hit a key on the keyboard), none of my code is firing off a WM_QUIT message, and when I run spy++ on my window i don't ever see this message. I changed the second param of my peekmessage to be my current windows hwnd, that seems to solve the problem, but I am guessing that will break any possibility of using a win32 context menu with this window (since the loop wont process child window messages)?
Does anyone have any clue where this WM_QUIT might be coming from, or how to track down where it is coming from?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement