Post by rahulPost by David LowndesPost by rahulIs there any way to make MFC application being notified at windows
shutdown event.
I have tried WM_QUERYWNDSESSION message but it didn't help.
WM_QUERYENDSESSION should be the message to handle.
When you say "it didn't help", what exactly do you mean?
Dave
I developed dialog based application in vc++ 6.0.
There is no OnQueryEndSession() function in classwizard i manually add
that in header file, source file and also in messagemap
(ON_WM_QUERYENDSESSION macro) and run application.
But when i put breakpoint and run application in debug mode and
shutdown PC breakpoint doesn't hit and PC shutdown.
Why??
Perhaps the problem is due to the app being dialog based.
I have a vc++ 6.0 application that has a a main frame derived from CFrameWnd.
WM_QUERYENDSESSION works for this program as follows.
IMPLEMENT_DYNCREATE(CMyMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMyMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CCMyMainFrame)
ON_WM_CREATE()
ON_WM_INITMENUPOPUP()
ON_WM_SIZE()
ON_WM_MENUSELECT()
ON_WM_MOVE()
ON_WM_QUERYENDSESSION()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// Ask the user if they want to save data before
// closing the application.
BOOL CMyMainFrame::OnQueryEndSession()
{
if (!CFrameWnd::OnQueryEndSession())
return FALSE;
if (!g_pDoc->AskSaveDataQuestion()) // part of my app
{
// User said "Cancel" so keep the windows session open
return FALSE;
}
return TRUE;
}