Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use Windows Power Management events

210 views
Skip to first unread message

Tyler Cruse

unread,
Oct 28, 2004, 9:31:43 AM10/28/04
to
I would like to get the WB_POWERBROADCAST messages and respond to them,
especially being able to retrun "BROADCAST_QUERY_DENY" response. The goal
is to either "handle" or "prevent" the system from hibernating
or going into standby mode. Windows apparently sends messages to every
application and waits for either a response
or a timeout (message not removed from queue) that indicates the pending
change of state. This is mainly an issue for laptop and
tablet systems that are running on battery power.

Has anyone found a straight forward solution for this issue?

The only approach that seems likely to work is to write a system service to
notify PB applications.


Philip Salgannik

unread,
Oct 28, 2004, 9:44:41 AM10/28/04
to
I am lost.
If "Windows apparently sends messages to EVERY application and waits for
either a response or a timeout (message not removed from queue) that
indicates the pending change of state" then why would you need to write a
system service to notify PB applications?
Why not monitor for it in the OTHER event and if the message is
Wm_POWERBROADCAST AND wparam is PBT_APMQUERYSUSPEND, then return
BROADCAST_QUERY_DENY if you deem it neccessary?
Or am I missing something...

pbm_thisusuallydoesnothelp:-))
Philip Salgannik

"Tyler Cruse" <tcr...@trlx.com> wrote in message
news:4180f4bf$1@forums-1-dub...
>I would like to get the Wm_POWERBROADCAST messages and respond to them,

Tyler Cruse

unread,
Oct 28, 2004, 1:36:51 PM10/28/04
to
1) It is not being setn as a WM_COMMAND message.
2) I would not know how to identify the message since the WPARM vaulues are
very generic 0-15.

I have not tried PeekMessage yet, but I would suspect that the message is
being processed up by PBVM already.


"Philip Salgannik" <philema...@comcast.net> wrote in message
news:4180f7c9@forums-1-dub...

philipsalgannik

unread,
Oct 28, 2004, 3:49:36 PM10/28/04
to
> 1) It is not being setn as a WM_COMMAND message.

From here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/wm_powerbroadcast.asp

The WM_POWERBROADCAST message is broadcast to an application
to notify it of power-management events.
A window receives this message through its
W-i-n-d-o-w-P-r-o-c function.

--So unless Sybase is specifically doing something with this
message, then you WILL see it in the OTHER event of the
window.


> 2) I would not know how to identify the message since the
> WPARM vaulues are very generic 0-15.

You will identify it by number, like so:
In the OTHER event of the window:
IF message.number = WM_POWERBROADCAST THEN
IF wparam = PBT_APMQUERYSUSPEND THEN
//don't think so
message.processed = TRUE
RETURN BROADCAST_QUERY_DENY
END IF
END IF

Tyler Cruse

unread,
Oct 28, 2004, 9:51:37 PM10/28/04
to
GetMessage and PeekMessage retrieve only messages that match the range
selected. So, it is not given that the Sybase runtime would see the message.
But for the sake of discussion lets assume that PBVM processes all messages
below 0x400. These messages would be processed in the windows message loop
for the application and any not handled passed to the other event.

Now, how would go about recognizing these messages; The "other" (event id =
pbm_other) has two parameters wparm and lparm. These match the parameters
passed in the Windows standard structure. Now, what the other event does
not do is identify the message type. In this case the wparm values range
from 0 to 16. So, even if you got the event, how would you recognize the
event as being one that you are interested in.

In the case of the say WM_USER messages, PB maps each WM_USER message to a
separate event, so that you know that WM_USER+1 message with wparm = 1 is
not mistaken for WM_USER+2 message with wparm = 1.

So, what am I missing?


<Philip Salgannik> wrote in message
news:41814d4c.61e...@sybase.com...

Philip Salgannik

unread,
Oct 29, 2004, 12:05:23 AM10/29/04
to

--
This is a FAQ, read Help, then search
www.groups.google.com/advanced_group_search

pbm_thisusuallydoesnothelp:-))
Philip Salgannik

"Tyler Cruse" <tcr...@trlx.com> wrote in message

news:4181a229$1@forums-1-dub...


> GetMessage and PeekMessage retrieve only messages that match the range
> selected. So, it is not given that the Sybase runtime would see the
> message. But for the sake of discussion lets assume that PBVM processes
> all messages below 0x400. These messages would be processed in the windows
> message loop for the application and any not handled passed to the other
> event.
>
> Now, how would go about recognizing these messages; The "other" (event id
> = pbm_other) has two parameters wparm and lparm. These match the
> parameters passed in the Windows standard structure. Now, what the other
> event does not do is identify the message type. In this case the wparm
> values range from 0 to 16. So, even if you got the event, how would you
> recognize the event as being one that you are interested in.
>
> In the case of the say WM_USER messages, PB maps each WM_USER message to a
> separate event, so that you know that WM_USER+1 message with wparm = 1 is
> not mistaken for WM_USER+2 message with wparm = 1.
>
> So, what am I missing?

message.number ?

Tyler Cruse

unread,
Oct 29, 2004, 10:41:11 AM10/29/04
to
Thanks. I had not thought that the message object would be involved with
the other event.


"Philip Salgannik" <philema...@comcast.net> wrote in message

news:4181c183$1@forums-1-dub...

0 new messages