• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 699
  • Last Modified:

intercept SHUTDOWN (given from WIN_NT task bar) msg in ur APPLN

How to intercept (in my running application) a SHUTDOWN msg issued from NT -TASKBAR?

I am not getting any WM_ENDSESSION or WM_QUERYENDSESSION or similar msgs in my MainWindow.

But if u see DevStudio, if u have any unsaved files, DevStudio warns u about it and asks u to save unsaved work.

How they are acheiving this???

Regards,
Venkatesan Pillai
Senior Software Enginner
AUTODESK Inc,
SanFransisco, CA -94903
Ph : 415-507-4878
E-Mail : dvenkat@cyberspace.org
0
dvenkat
Asked:
dvenkat
1 Solution
 
jhanceCommented:
If you are using MFC you need to do the following:

In you message map add the ON_WM_QUERYENDSESSION():

BEGIN_MESSAGE_MAP(CLogStatsDlg, CDialog)
      //{{AFX_MSG_MAP(CLogStatsDlg)
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
      ON_WM_QUERYENDSESSION()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

Then add the OnQueryEndSession() member function:

BOOL CLogStatsDlg::OnQueryEndSession()
{
      //if (!CDialog::OnQueryEndSession())
      //      return FALSE;
      
      // TODO: Add your specialized query end session code here
      AfxMessageBox("QUERYENDSESSION", MB_OK);
      return FALSE;  // Always refuse to shutdown!
}
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now