Compartilhar via


Enabling a Backlight

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

If your hardware is equipped with a backlight, implement this functionality by setting the Backlight component as a Cplmain component in your Cesysgen.bat file. This component enables the backlight and allows your users to control the backlight settings.

The following example shows a sample entry in a Cesysgen.bat file that defines the Backlight as a Cplmain component.

set CPLMAIN_COMPONENTS=%CPLMAIN_COMPONENTS% backlight

In addition to including the Backlight component in your OS design, you should also create the following registry key.

[HKEY_CURRENT_USER\ControlPanel\Backlight]

Once the backlight is enabled, your users can set separate backlight timeouts for battery and AC power. When a user changes these settings, the Control Panel updates the following registry values. Note that the units for these values are in seconds.

[HKEY_CURRENT_USER\ControlPanel\Backlight]
    BatteryTimeout = DWORD
    ACTimeout = DWORD

Your display driver should read these values from the registry and turn off the backlight at the appropriate timeout. You can configure the initial values of these timeouts by setting these registry values to the appropriate defaults in your Project.reg file.

Whenever a change occurs in the timeout values, the Control Panel signals an event named BackLightChangeEvent. This event eliminates the need for your display driver to constantly read the registry to monitor the timeout values for changes.

The following example shows a display driver with a background thread that waits for the BackLightChangeEvent event.

//  Create an auto-reset named event, initially not set.
//  CPL will signal this when something changes.
HANDLE   hEvent = CreateEvent(NULL, FALSE, FALSE, "BackLightChangeEvent")
for(;;)
{
   //  Wait on this event.
   WaitForSingleObject(hEvent, INFINITE)
   //  Awake. CPL must have changed some settings.
   //  Read new settings from registry and do something useful
   //  with the new settings.
   //  Now loop back and wait again.
}

See Also

Concepts

Control Panel Applications
Adding an Advanced Backlight Dialog Box