Solved

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

Posted on 1998-01-02
1
661 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now