Keep Backlight on

D

Dave

Greetings,

Does anybody have some code that will prevent the backlight from
automatically turning off?

Thanks,

-Dave
 
D

Dave

Peter,

Thanks, I'll give the code a try. Where should I put this code in my
application?

-Dave
 
P

Peter Foot [MVP]

You can drop the class into your code, call the Activate method to request
the power state, then call Release to free up the handle before your app
closes, or whenever you want to restore default behaviour. You can Activate
/ Release multiple times if for example you only want to force the backlight
during a specific operation e.g. playing a video or similar. There isn't any
checking in the code to ensure that the handle was freed before being
assigned again but that would be easy to add by calling Release within the
Activate method and if the handle is still valid (not 0) then it will first
release the handle before requesting anew. You may want to change the code
to expose the power state you require (the example only specifies full on).
Though not all devices will support all the powerstates available.

Peter
 
D

Dieter

When I cange powerstate to D3 or D4 does it onlx change backlight or
also other behavior of device?

Reaction of keypresses , CPu speed etc?
 
P

Peter Foot [MVP]

It should only affect the device which you pass in the identifier for - e.g.
BKL1: in such a way it should be possible to power up and down other parts
of the system but I would be very careful!

Peter
 
D

Dieter

The code works fine, I can set backlight to half power an my SP3.

Problem is , that keypresses overide it , on keypresses backlight goes
to full power for the defined time in settings.

So i changed the setting for backlight in registry to 0
programmatically.
But this has only effect after a reset, cause driver backlight has not
got the changes.

Therefore is the backlightchangeevent.
U see it at the end of the code i posted.


But is C# , i tried to translate it to VB.Net, but failed.
Never worked with events before.


So I requested the full code in VB.net to raise theat event.
Anyone is so kind to do ??

After this , keypresses have no effect to the settings from ur code.
-------------------------------------------------------------------------

// Signal display driver to update
HANDLE hBackLightEvent = CreateEvent( NULL, FALSE, TRUE,
TEXT("BackLightChangeEvent"));
if (hBackLightEvent)
{
SetEvent(hBackLightEvent);
CloseHandle(hBackLightEvent);
}
 
D

Dieter

Dim hevent As IntPtr = OpenNETCF.Win32.Core.CreateEvent(False,
False, "BackLightChangeEvent")

If (Not IsNothing(hevent)) Then
OpenNETCF.Win32.Core.SetEvent(hevent)
OpenNETCF.Win32.Core.ResetEvent(hevent)
End If


now I can set backlight on SP on half, keypresses dont override it,
and ending my apps BacklightTimeout is reset to old behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top