Probably a weird and meaningless topic header :) Here's what I have: my
application makes it own windows using win32api and such so I don't need MFC
for that. But I do use MFC for a few things (eg easy wizard dialogs). So I
cheated and did it the following way (which I assume is the normal way for
this)

BOOL CMyApp::InitInstance()
{
//make my windows

while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//clean up code
return FALSE;
}

Therefore I get MFC functionally without having to use MFC everywhere (I
dislike MFC) Ok, now my problem. When windows shutdown I don't receive any
notification, ie the clean up code doesn't get executed above. Any ideas on
how I can catch the shutdown and therefore do some needed clean up code.
When the program exits normally, eg alt-f4 or close button, everything works
fine.

thanks,
Adam Hart

Re: mfc wrapper not passing quit message by James

James
Tue Aug 19 11:38:56 CDT 2003

Try adding the following to your Mainfrm.cpp or main message
handling routines

ON_WM_CLOSE()

and then add a handler which
does your necessary shutdown processing.

void CMainFrame::OnClose()
{
shutdown and delete stuff here, main window is closing
}

This will also be called if the user clicks on the "X" in the upper right
corner and shuts down you app in that manner.


J


"Adam Hart" <myfirstname@adamhart.net> wrote in message
news:unM1qquYDHA.2384@tk2msftngp13.phx.gbl...
> Probably a weird and meaningless topic header :) Here's what I have: my
> application makes it own windows using win32api and such so I don't need
MFC
> for that. But I do use MFC for a few things (eg easy wizard dialogs). So I
> cheated and did it the following way (which I assume is the normal way for
> this)
>
> BOOL CMyApp::InitInstance()
> {
> //make my windows
>
> while (GetMessage(&msg, NULL, 0, 0) > 0)
> {
> TranslateMessage(&msg);
> DispatchMessage(&msg);
> }
> //clean up code
> return FALSE;
> }
>
> Therefore I get MFC functionally without having to use MFC everywhere (I
> dislike MFC) Ok, now my problem. When windows shutdown I don't receive any
> notification, ie the clean up code doesn't get executed above. Any ideas
on
> how I can catch the shutdown and therefore do some needed clean up code.
> When the program exits normally, eg alt-f4 or close button, everything
works
> fine.
>
> thanks,
> Adam Hart
>
>