Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 950
  • Last Modified:

Catching WM_POWERBROADCAST message

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
markparr
Asked:
markparr
1 Solution
 
chensuCommented:
Catch it in your main frame window as follows.

ON_MESSAGE(WM_POWERBROADCAST, OnPowerBroadcast)

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

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now