Solved

Catching WM_POWERBROADCAST message

Posted on 1998-08-17
1
898 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

12 Experts available now in Live!

Get 1:1 Help Now