Solved

SDI main frame and WM_ENDSESSION

Posted on 2004-10-10
2
1,069 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

11 Experts available now in Live!

Get 1:1 Help Now