Solved

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

Posted on 1998-01-02
1
674 Views
Last Modified: 2013-12-03
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
Comment
Question by:dvenkat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 20 total points
ID: 1409813
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question