Archived

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

Dustino

Program won't exit

Recommended Posts

The program I am working on will not close. When I close it the window will close and it will leave the taskbar, but if I look in the Close Program window the program will still be there. And I know the program is still open because if I try to compile it again it says it can''t write to the exe. So to close it I have to close it through the Close Program window. Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


Handle the WM_CLOSE message by using PostQuitMessage(0);

Share this post


Link to post
Share on other sites
I already am.

case WM_CLOSE:
{
OA_Shutdown();

wglMakeCurrent(hDC, NULL);
wglDeleteContext(hRC);

PostQuitMessage(0);
} break;

Share this post


Link to post
Share on other sites
If your program is a windows program try adding to your WNDPROC
  
case WM_CLOSE:
PostQuitMessage (0); // or PostMessage (hWnd, WM_QUIT, 0, 0);

return 0;



If its a MFC program a description of your message handlers would help

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Do you have a condition to break out of your message loop when msg.message == WM_QUIT?

Share this post


Link to post
Share on other sites
I have the following in WinMain()

while (!done)
{
PeekMessage(&msg, hWnd, NULL, NULL, PM_REMOVE);

if (msg.message == WM_QUIT)
{
done = true;
}
else
{
OA_RenderScene();

SwapBuffers(g_HDC);
TranslateMessage(&msg);
DispatchMessage(&msg);
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


Have you set a breakpoint on the line done=true; and see if it hits it? Then try to follow from there?

Or, better yet, set a breakpoint or trace (OutputDebugString) in your WM_CLOSE block and see if that is being reached.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


no..no..no..

I think I am losing my mind sometimes..

In WM_CLOSE call DestroyWindow(hwnd); Then in response to WM_DESTROY call PostQuitMessage(0);

Share this post


Link to post
Share on other sites
Yes put the PostQuitMessage() in the WM_DESTROY().
For the WM_CLOSE I found that sometimes I would get an empty box on my taskbar when I used DestroyWindow(), so I switched to:

PostMessage( window, WM_DESTROY, (WPARAM)0, (LPARAM)0);

and it seemed to clear it up. Strange because it seems to do the exact same thing?

Share this post


Link to post
Share on other sites