System Shutdown
-
Hi How to capture System Shutdown/Restart/Stand By messeges from a Visual C/C++ Program thanx in advance by KK
Take a look at
WM_QUERYENDSESSION
andWM_ENDSESSION
.
Nibu thomas Software Developer
-
Take a look at
WM_QUERYENDSESSION
andWM_ENDSESSION
.
Nibu thomas Software Developer
Hold on!, i've been trying to capture these messages in the PreTranslateMessage, but i dont know what mistake i'm making. its not getting trapped. can you help me out?
BOOL CTESTMFC2Dlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_QUERYENDSESSION) { if(pMsg->lParam==0x80000000) { /*code here*/ } } if(pMsg->message==WM_ENDSESSION) { /*code here*/ } return CDialog::PreTranslateMessage(pMsg); }
Actually the 0x80000000 is to check if its a LogOff. the owner of this thread may also like to see your reply. ;)
VuNic
-
Hi How to capture System Shutdown/Restart/Stand By messeges from a Visual C/C++ Program thanx in advance by KK
-
BOOL CMainFrame::OnQueryEndSession() { if (!CFrameWnd::OnQueryEndSession()) return FALSE; AfxMessageBox("I caught System ShutDown"); return TRUE; }:laugh: also c WM_ENDSESSION
-
afx_msg void CShutWindowDlg::OnEndSession( BOOL bEnding ) { AfxMessageBox("Shut Down Message Caught"); } :laugh:
Did you chage your post?? what's that afx_msg void?? it only returns a BOOL right? Btw, still its not working. I tried both ::OnEndSession(BOOL b) and ::OnQueryEndSession() BOOL CTESTMFC2Dlg::OnEndSession(BOOL bEnding) { //Not entering here :( } BOOL CTESTMFC2Dlg::OnQueryEndSession() { // Not entering here :( } What'd have gone wrong?:confused:
VuNic
-
afx_msg void CShutWindowDlg::OnEndSession( BOOL bEnding ) { AfxMessageBox("System ShutDown Message Caught"); } Handel WM_ENDSESSION Message :laugh:
-
Don't try adding those functions. Instead, go to your dialog view (where you can manipulate the button/textbox fields) click on the dialog somewhere. From there, go to the Properties tab. This is the place where you would normally set the button/textbox name, readonly, etc. Instead, click on the button next to the little Lightning bolt that is labeled "Messages." From there, scroll down until you see "WM_QUERYENDSESSION", click on that, and add OnQueryEndSession. From there your function will be added and implimented, and you can change what you're testing for inside of that. da Big_R
-
Don't try adding those functions. Instead, go to your dialog view (where you can manipulate the button/textbox fields) click on the dialog somewhere. From there, go to the Properties tab. This is the place where you would normally set the button/textbox name, readonly, etc. Instead, click on the button next to the little Lightning bolt that is labeled "Messages." From there, scroll down until you see "WM_QUERYENDSESSION", click on that, and add OnQueryEndSession. From there your function will be added and implimented, and you can change what you're testing for inside of that. da Big_R