Is there any way to make MFC application being notified at windows
shutdown event.
I have tried WM_QUERYWNDSESSION message but it didn't help.
Can anybody send me code to do that??
On May 16, 12:00 pm, David Lowndes <Dav...@example.invalid> wrote:
> >Is 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??
developed a dialog based application in VC++ 6.0. I manually added
afx_msg BOOL OnQueryEndSession() in header file
ON_WM_QUERYENDSESSION() in message macro
and
BOOL CSomeDlg::OnQueryEndSession()
{
return FALSE;
}
in cpp file.
When I run the application in debug mode and put the breakpoint in
above
function and then shutdown pc
breakpoint should be hit.
but breakpoint didn't hit and windows shuts down normally.
---------------------------
I want my application displays some message box before windows shut
down..
How this could be done?
On Tue, 15 May 2012 21:27:57 -0700 (PDT), rahul <hyrahu...@gmail.com>
wrote:
>Is there any way to make MFC application being notified at windows
>shutdown event.
>I have tried WM_QUERYWNDSESSION message but it didn't help.
>Can anybody send me code to do that??
> On May 16, 12:00 pm, David Lowndes <Dav...@example.invalid> wrote:
>> >Is 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??
I think that Windows doesn't send this message to every window, only top level windows. Try using Spy++ to see if your window is a child of another window, or use GetAncestor(GA_PARENT), which should return 0.
> developed a dialog based application in VC++ 6.0. I manually added
>afx_msg BOOL OnQueryEndSession() in header file
>ON_WM_QUERYENDSESSION() in message macro
>and
>BOOL CSomeDlg::OnQueryEndSession()
>{
> return FALSE;
>}
>in cpp file.
>When I run the application in debug mode and put the breakpoint in
>above
>function and then shutdown pc
>breakpoint should be hit.
>but breakpoint didn't hit and windows shuts down normally.
I don't know what you've got wrong - everything you've mentioned looks
fine. I've just added a handler for WM_QUERYENDSESSION to a default
MFC dialog application using VS2008 and the breakpoint was hit. I can
see no real differences in what the tool generated and what you
mentioned above.
> > On May 16, 12:00 pm, David Lowndes <Dav...@example.invalid> wrote:
> >> >Is 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??
> I think that Windows doesn't send this message to every window, only top
> level windows. Try using Spy++ to see if your window is a child of another
> window, or use GetAncestor(GA_PARENT), which should return 0.
Main dialog( in which i kept handler) in dialod based application is
top level window.
> > developed a dialog based application in VC++ 6.0. I manually added
> >afx_msg BOOL OnQueryEndSession() in header file
> >ON_WM_QUERYENDSESSION() in message macro
> >and
> >BOOL CSomeDlg::OnQueryEndSession()
> >{
> > return FALSE;
> >}
> >in cpp file.
> >When I run the application in debug mode and put the breakpoint in
> >above
> >function and then shutdown pc
> >breakpoint should be hit.
> >but breakpoint didn't hit and windows shuts down normally.
> I don't know what you've got wrong - everything you've mentioned looks
> fine. I've just added a handler for WM_QUERYENDSESSION to a default
> MFC dialog application using VS2008 and the breakpoint was hit. I can
> see no real differences in what the tool generated and what you
> mentioned above.
> Dave
I just want to know, if everything goes right, and if we return FALSE
in OnQueryEndSession() what will heppan? Windows will not shut down pc?
> >I just want to know, if everything goes right, and if we return FALSE
>>in OnQueryEndSession() what will heppan? Windows will not shut down pc?
> That's what the documentation says.
Actually, it could in some cases like in terminal servers. It's very common for administrators to log off disconnected sessions, or set it to auto log off if disconnected after a period of time. When that happens, your application that might be displaying "Do you want to save?" prompt will be allowed only 5 seconds to terminate, after that, the process is automatically killed. This is because the session is disconnected and invisible, so no one is responding to the Save prompt. This is documented somewhere in MSDN.
>On May 16, 12:00 pm, David Lowndes <Dav...@example.invalid> wrote:
>> >Is 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.
On Wed, 16 May 2012 01:03:16 -0700 (PDT), rahul <hyrahu...@gmail.com>
wrote:
>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
It's being filtered out. Go to the Class Info tab in ClassWizard and
change the message filter to Window.
I can't see any error in the method you've posted. Did you add