Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SDI main frame and WM_ENDSESSION

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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