Solved

Catching WM_POWERBROADCAST message

Posted on 1998-08-17
1
906 Views
Last Modified: 2013-11-20
I'm trying to write a program that when used on a laptop will be able to detect a change from AC to battery power by catching the WM_POWERBROADCAST message.  Using Spy++, I see the message being sent to my application.  In an overwrite of PreTranslateMessage, I am looking for WM_POWERBROADCAST and trying to display a message indicating the message has been caught.  However, this has yet to work.

What am I missing in order to catch this message -- does it have to be caught before PreTranslateMessage or what?

I'm using VC++ 5.0 under Win 95.

Thanks,
Mark
0
Comment
Question by:markparr
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1320938
Catch it in your main frame window as follows.

ON_MESSAGE(WM_POWERBROADCAST, OnPowerBroadcast)

LONG CMyFrameWnd::OnPowerBroadcast(UINT wParam, LONG lParam)
{
    //...
}

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

20 Experts available now in Live!

Get 1:1 Help Now