Archived

This topic is now archived and is closed to further replies.

clrscr

Hear Ye, Hear Ye

Recommended Posts

clrscr    158
Hello, I am programming windows and OpenGL with C++ and Visual Studio 6.0, and when I close my program the window will go away,however the .exe will stay in the memory, so If I go to link it again I get in error saying it cant open the file for writing. The only way I can close my program is by hitting ctrl-alt-del and closing my program from there. Any ideas? "You can observe a lot just by watching."- Yogi Berra

Share this post


Link to post
Share on other sites
strtok    191
If you''re using MFC, this shouldn''t happen. If however you are using straight Win32 API calls, you''re probably not posting the WM_QUIT message when you''re window closes. You need to call PostQuitMessage(), and make sure you break out of your message loop when you get WM_QUIT. Hope this helps.

Share this post


Link to post
Share on other sites
strtok    191
If you''re using MFC, this shouldn''t happen. If, however, you are using straight Win32 API calls, you''re probably not posting the WM_QUIT message when your window closes. You need to call PostQuitMessage(), and make sure you break out of your message loop when you get WM_QUIT. Hope this helps.

Share this post


Link to post
Share on other sites
clrscr    158
I'm using straight Win32 API calls, and I PostQuitMessage(0) when I get WM_CLOSE, is that the right place to put it? I also shutdown my window there and that works fine. I also checked my loop and that exits when it should.

"You can observe a lot just by watching."- Yogi Berra

Edited by - clrscr on December 11, 2001 8:01:45 PM

Edited by - clrscr on December 11, 2001 8:02:00 PM

Share this post


Link to post
Share on other sites
AdmiralBinary    100
I get the same problem a lot of the time, and here is my solution:

  
BOOL bQuit = FALSE;
while (!bQuit)
{
if (PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} else
{
bQuit = TRUE;
}
}
DoStuff();
}

I hope this helps...

---------------

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites
AdmiralBinary    100
quote:
Correction. You should be calling DestroyWindow() when you get WM_CLOSE and then calling PostQuitMessage() when you get WM_DESTROY.

Maybe, maybe...but it works anyway... Windows working behind my back again?

---------------

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites