Window Loop

Started by
5 comments, last by quaker 18 years ago
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.
Advertisement
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);
}
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?

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

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!


Ya I forgot to mention it's a D3D application. when I take out the D3D code it works fine.
Ya I forgot to mention it's a D3D application. when I take out the D3D code it works fine.

This topic is closed to new replies.

Advertisement