Solved

SDI main frame and WM_ENDSESSION

Posted on 2004-10-10
2
1,082 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 54
deburging in oracle form 12 112
if loop in java 3 163
Is there a simple front-end menu system. 9 122
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.

733 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