search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
Mobile Application Development GroupsView
Pocketpc
Pocketpc Activesync
Pocketpc Developer
Pocketpc Phone_Edition
Windowsce App Development
Windowsce Embedded
Windowsce Platbuilder

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Application Development
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Pocketpc Developer Posts  Ask A New Question 

Why does this Backlight turn on/off class not work on my device - Wolfgang Hauer

Wednesday, March 28, 2007 12:57 PM

Hi all!

My device is a HTC P3300 (Phone + GPS) PDA.
I have from http://www.peterfoot.net/KeepYourSmartphoneBacklightOn.aspx
grabbed a class wich  should be able to turn the backlight ON/OFF. But it
does'nt work. I got a handle from
SetPowerRequirement(). But no change. Any ideas?

Thanks
Wolfgang


Public Class Backlight
Private Declare Function SetPowerRequirement Lib "coredll.dll" (ByVal
pvDevice As String, ByVal DeviceState As PowerState, ByVal DeviceFlags As
Integer, ByVal pvSystemState As IntPtr, ByVal StateFlags As Integer) As
IntPtr
Private Declare Function ReleasePowerRequirement Lib "coredll.dll" (ByVal
handle As IntPtr) As Integer
'ensure the power requirement is released
Protected Overrides Sub Finalize()
Release()
End Sub
'handle to the power requirement
Private handle As IntPtr
Private Enum PowerState
PwrDeviceUnspecified = -1
D0 = 0 'full on _
D1 = 1 'low power
D2 = 2 'standby
D3 = 3 'sleep
D4 = 4 'off
PwrDeviceMaximum = 5
End Enum
'keep the backlight lit
Public Sub Activate()
'request full power
handle = SetPowerRequirement("BKL1:", PowerState.D0, 1, IntPtr.Zero, 0)
End Sub
'keep the backlight lit
Public Sub DeActivate()
'request no power
handle = SetPowerRequirement("BKL1:", PowerState.D4, 1, IntPtr.Zero, 0)
End Sub
Public Function PowerSettingChanged() As Boolean
If handle = IntPtr.Zero Then
Return False
Else
Return True
End If
End Function
'release power requirement
Public Sub Release()
If handle.ToInt32() <> 0 Then
Dim result As Integer
result = ReleasePowerRequirement(handle)
handle = IntPtr.Zero
End If
End Sub
End Class
reply
 

Device names can vary between different device types, you'll need to find an - Peter Foot [MVP]

Wednesday, March 28, 2007 4:03 PM

Device names can vary between different device types, you'll need to find an
alternative for BKL1: used in the example. Device names are stored in the
registry.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com
reply

Thanks Peter! - Wolfgang Hauer

Wednesday, March 28, 2007 5:11 PM

Thanks Peter!

So i  can asume that there is no generic way to find out the devicename of
the backlight device?
And why i get a valid looking handle ?

Wolfgang
reply

Hi! - Wolfgang Hauer

Thursday, March 29, 2007 3:32 AM

Hi!

I have checked HKLM/drivers/active/builtin/backlight. The prefik is "BKL"
and the index is 1.
Any other idea?

Wolfgang
reply

SetPowerRequirement won't turn the light on and off on its own, all it does is - Uncle Marvo

Thursday, March 29, 2007 3:43 AM

SetPowerRequirement won't turn the light on and off on its own, all it does
is to tell Power Manager that YOU don't want it (or DO want it).

If something else overrides it, it will stay on (or off).
reply

Hi! - Wolfgang Hauer

Thursday, March 29, 2007 5:34 AM

Hi!

Is there a way to tell that damned thing that I am the master because I have
spend the bucks!!!

Or can i turn the complete LCD off /on

Wolfgang
reply

Hammer? - NeilH

Thursday, March 29, 2007 5:36 AM

Hammer?

have
Newsbeitrag
it
As
(ByVal
reply

Why does this Backlight turn on/off class not work on my device - Uncle Marvo

Thursday, March 29, 2007 5:42 AM

In reply to NeilH (neil@nospam.uk) who wrote this in


Good option. The other one is SetPowerState() :-)
reply

PS There is a good reason why you should really not use SetPowerState() over - Uncle Marvo

Thursday, March 29, 2007 5:44 AM

PS There is a good reason why you should really not use SetPowerState() over
SetPowerRequirement().

A really silly idea to use it on BTH1 etc, but I should think that turning
the backlight on/off won't have any damaging consequences.

Unc
reply

Why does this Backlight turn on/off class not work on my device - Wolfgang Hauer

Thursday, March 29, 2007 6:10 AM

I will post a new question: I need to save power!

Wolfgang
reply

hmmm.i've always assumed that the backlight device is BKL1. - The PocketTV Team

Thursday, March 29, 2007 6:57 AM

hmmm.

i've always assumed that the backlight device is BKL1.

the idea of SetPowerRequirement was that applications can programatically
configure the backlight, rather than use various tricks that are device
dependent.

if the name of the backlight device is something random that applications
must guess for each device, then thise would seem to defeat the original
purpose, no?

if there is a guaranteed method to recover the backlight device name, what
is it?  what registry key must be accessed?

thanks.
reply

Why does this Backlight turn on/off class not work on my device - The PocketTV Team

Thursday, March 29, 2007 6:59 AM

on some devices, it is called:

HKLM/drivers/active/builtin/FrontLight (i'm not kidding!)

so i guess that getting the name of the backlight device is a big guessing
game...

why can't that be standardized?
reply

Why does this Backlight turn on/off class not work on my device - Peter Foot [MVP]

Thursday, March 29, 2007 7:56 AM

For all the smartphones I've seen it's always been BKL1:, for Pocket PC
2003s I've seen a variety used, though maybe this has improved in more
recent versions, I haven't tried the code on WM5.0 Pocket PCs.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com
reply
 
 

Previous Microsoft Pocketpc Developer conversation.