Solved

Catching WM_POWERBROADCAST message

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 133
format the code in java 6 115
zeroFront challenge 7 134
scoreUp challenge 14 72
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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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