Click here to get back home

Re: Why does this Backlight turn on/off class not work on my device

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: Why does this Backlight turn on/off class not work on my device The PocketTV Team 03-29-2007
Posted by The PocketTV Team on March 29, 2007, 7:57 am
Please log in for more thread options
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.

> 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
>
>> 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
>>
>



Posted by Peter Foot [MVP] on March 29, 2007, 8:56 am
Please log in for more thread options
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

> 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.
>
>> 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
>>
>>> 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
>>>
>>
>
>


Similar ThreadsPosted
TURN $5 INTO $15,000 IN 30 DAYS! THIS WORK!!! PAYPAL MAGIC! October 27, 2005, 5:13 pm
eVC++4 Remove Tools don't work Smartphone device July 28, 2005, 9:41 am
Backlight turns on when thread wakes up. March 5, 2008, 3:05 pm
Class not registered May 14, 2008, 5:05 am
How to turn on/off irDA? June 21, 2005, 9:29 am
Turn on/off Wireless? November 19, 2006, 9:03 am
custom CBitmap class July 18, 2005, 3:50 am
FileSystemWatcher class for NetFramework2 August 11, 2005, 12:52 am
Can’t override BACK key with Class Specified March 1, 2006, 7:32 pm
How to turn on/off flight mode? June 6, 2005, 2:39 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap