[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SDI main frame and WM_ENDSESSION

Posted on 2004-10-10
2
Medium Priority
?
1,120 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Loops Section Overview

830 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