Solved

SDI main frame and WM_ENDSESSION

Posted on 2004-10-10
2
1,087 Views
Last Modified: 2013-11-20
I added WM_ENDSESSION handler to CMainFrame class of SDI application:

void CMainFrame::OnEndSession(BOOL bEnding)
{
    CFrameWnd::OnEndSession(bEnding);

    if ( bEnding )
        Beep(300, 300);
}

When I reboot/log off while program is running, this function is not called. If I do the same in MDI application, it works - I hear beep. How can I handle computer shitdown/log off event in SDI application?
0
Comment
Question by:AlexFM
[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
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 12272304
The reason seems to lie in the call to

CFrameWnd::OnEndSession(bEnding);

because it does

// when Windows session ends, close all documents
void CFrameWnd::OnEndSession(BOOL bEnding)
{
    if (!bEnding)
        return;

    CWinApp* pApp = AfxGetApp();
    if (pApp != NULL && pApp->m_pMainWnd == this)
    {
        AfxOleSetUserCtrl(TRUE);    // keeps from randomly shutting down
        pApp->CloseAllDocuments(TRUE);

        // allow application to save settings, etc.
        pApp->ExitInstance();
    }
}

call ExitInstance() directly. You'll hear the beep if you call the base class' implementation after your code.

BTW:

>>How can I handle computer shitdown/log off event in SDI application?

I *love* that typo, it made my day :o)
0
 
LVL 48

Author Comment

by:AlexFM
ID: 12305732
Thanks :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

724 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