• ### Announcements

#### Archived

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

# Hear Ye, Hear Ye

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
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 on other sites
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 on other sites
...and, in the message receiver thingy:

  case WM_DESTROY:PostQuitMessage(0);break;

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

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

##### Share on other sites
That fixed it, thanks a lot for the help

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

##### Share on other sites
Correction. You should be calling DestroyWindow() when you get WM_CLOSE and then calling PostQuitMessage() when you get WM_DESTROY.

##### Share on other sites
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 on other sites
Oh, strtok, I use DefWindowProc if i don''t catch the msg - that must be thuh reason

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

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

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34