process still running, and other strangeness

Started by
6 comments, last by krez 20 years, 4 months ago
i am making a MDI app (straight win32, no MFC) with openGL (it is for editing multiple tilemaps at once)... and strange things are happening! first and foremost, when i close the program (with the "X" button, or the menu which posts a WM_CLOSE to the main MDI window), there is still a process running for it. i also tried posting a WM_QUIT, which gives the same results. am i missing something here? also, when i maximize one of the child windows, and then close it while maximized, both the system icon (in the upper left of the child window) and the "min/max/X" buttons remain behind. normally the next child window will become maximized, but instead the rest are staying put and the buttons don''t go away. so, if i maximize and then close several windows, the buttons and icons line up along the top of my main window. anyone know of such things, and if so how to fix them? thanks!
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Advertisement
Make sure your message loop is EXACTLY how do it over in the WinProg tutorials. Subtle differences in that can really screw you up. Also, you say PostQuitMessage(0); on receipt of WM_CLOSE in your main window to properly shut the application down. At that point you should be cleaning things up (or with destructors), killing threads, destroying windows, etc etc etc.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
yah, i''ll have to check it over with a fine-tooth comb when i wake up later... it is so hard to think when the sun is up!

if anyone thinks of anything offhand feel free to post it!
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
I wouldn''t really handle WM_QUIT. That''s not too good of an idea, unless you also call DefWindowProc.

Usually, the pro-quo is to handle WM_CLOSE, and call PostQuitMessage(0) from there.
daerid@gmail.com
quote:Original post by krez
i am making a MDI app (straight win32, no MFC) with openGL (it is for editing multiple tilemaps at once)... and strange things are happening!

first and foremost, when i close the program (with the "X" button, or the menu which posts a WM_CLOSE to the main MDI window), there is still a process running for it. i also tried posting a WM_QUIT, which gives the same results. am i missing something here?

also, when i maximize one of the child windows, and then close it while maximized, both the system icon (in the upper left of the child window) and the "min/max/X" buttons remain behind. normally the next child window will become maximized, but instead the rest are staying put and the buttons don''t go away. so, if i maximize and then close several windows, the buttons and icons line up along the top of my main window.

anyone know of such things, and if so how to fix them?

thanks!


I could be wrong, but from what I took from MFC, MDI applications are handled different from SDI applications, in that instead of having just a main window, as with an SDI application, an MDI application has a parent window and child windows for the various documents that are open. Is it possible you''re handling the message for the wrong window? Not sure if that helps, but thought it worth mentioning.

-hellz
i am not handling the WM_QUIT... i meant i was calling "PostQuitMessage()"...

in the WM_CLOSE handler, i loop through the open child windows and close them (by SendMessage()ing a WM_CLOSE to them), then call DestroyWindow(hwnd).

in WM_DESTROY, it simply PostQuitMessage()es.

this is nearly identical to a (fully-working) openGL-with-MDI-windows tutorial i found. except that mine doesn''t work

hmmmm...
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
ok... harrumph!

i was using:
while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) != WM_QUIT) {} 

for my main loop... and the example i was basing my ideas off used:
while(GetMessage(&Msg, NULL, 0, 0)) {} 


so, now i don''t have the process still running after i close the window (strange, i guess that is yet another difference between normal apps and MDI apps)...

does anyone have a clue about my other problem? the one with the child windows leaving their "X", "_", "[]" buttons behind when i close them while maximized?
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
well, i don''t think anyone cares, but i figured it out and will share.

you see, i have a class with info for each child window, and a pointer to it attached to each window (using the SetWindowLong() function). when the child windows received a WM_CLOSE, it would delete the pointer and remove it from the list; inside the destructor, i called DestroyWindow(). i am assuming that calling DestroyWindow() before DefMDIChildProc() was causing the problem, since when i removed that line it worked properly.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

This topic is closed to new replies.

Advertisement