Window Loop
Why I get application error, break point reached ... when I close the program or send close message?
while (1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
.....
}
}
Thanks.
Try doing as follows
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)
while ( msg.message != WM_QUIT )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
}
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)
while ( msg.message != WM_QUIT )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
}
How are you handling the close and destroy window messages in your win proc? I ask because your while loop looks fine to me.
Yeah your message loop is fine, I just do a while (!done) then when I hit WM_QUIT and change done to true and exit gracefully. I think its neater looking and easier to follow then a break like yours but it's looks nothing more.
What's the actual error you are getting and how are you handling, like LostSource asked, your WndProc for the close/destroy messages?
What's the actual error you are getting and how are you handling, like LostSource asked, your WndProc for the close/destroy messages?
Actually I handle the following message:
WM_DESTROY:
PostQuitMessage(0);
And the application error message:
The exception breakpoint
A breakpoint has been reached.
(0x80000003) occurred in the application at location 0x...
Strange!
WM_DESTROY:
PostQuitMessage(0);
And the application error message:
The exception breakpoint
A breakpoint has been reached.
(0x80000003) occurred in the application at location 0x...
Strange!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement