Handle the WM_POWERBROADCAST message provided by the Windows* operating system and scaling features accordingly. WM_POWERBROADCAST is a Windows message sent to applications to indicate system-wide power state changes.
Hardware advances have made mobile systems lighter and more energy efficient. In addition to these advances, software developers can make applications power-aware such that they enable users to work for longer periods of time before having to reconnect to recharge the system battery. For example, when on AC power, an anti-virus scanner would run in a full-featured fashion, providing file scanning on all files opened and also running periodic system-wide scans. When on battery power, the scanner could defer the system-wide scans until a later time and continue processing safely, analyzing just the open files.
Under Windows, applications are notified of system power changes through the WM_POWERBROADCAST message. Note that the WM_POWER message is now obsolete and should be replaced with WM_POWERBROADCAST.
Handle messages through the standard message loop using GetMessage(). The WM_POWERBROADCAST message comes with two parameters: wParam and lParam. The wParam parameter can be a number of items that specify the event received. The documentation for each of these is as follows:
|PBT_APMBATTERYLOW||Battery power is low.|
|PBT_APMOEMEVENT||OEM-defined event occurred.|
|PBT_APMPOWERSTATUSCHANGE||Power status has changed.|
|PBT_APMQUERYSUSPEND||Request for permission to suspend.|
|PBT_APMQUERYSUSPENDFAILED||Suspension request denied.|
|PBT_APMRESUMEAUTOMATIC||Operation resuming automatically after event.|
|PBT_APMRESUMECRITICAL||Operation resuming after critical suspension.|
|PBT_APMRESUMESUSPEND||Operation resuming after suspension.|
|PBT_APMSUSPEND||System is suspending operation.|
lParam is function-specific and is not generally used.
The source for this item, cited below, provides further detail and use cases. Additional introd uctory material is available from the MSDN documentation at http://msdn.microsoft.com/*.