Solved

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

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…

738 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