Program won't exit

Started by
9 comments, last by Dustino 22 years, 3 months ago
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.
Advertisement


Handle the WM_CLOSE message by using PostQuitMessage(0);
I already am.

case WM_CLOSE:
{
OA_Shutdown();

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

PostQuitMessage(0);
} break;
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
humanity will always be slaved by its ignorance

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

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);
}


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.

try
  case WM_QUIT:case WM_CLOSE:  PostQuitMessage(0);  return 0;case WM_MOUSEMOVE: // ...etc  
[source]#define JESUS 1[/source]


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);

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?

This topic is closed to new replies.

Advertisement