Backlight Message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have successfully changed the contrast settings in the registry but i can't
seem to get the code right to fire the BackLightChangeEvent. Please Help I'm
getting a missing method exception. I'm not event sure if i'm on the right
track either.

Public Declare Function CreateEvent Lib "CoreDll.dll" (
ByVal lpEventAttributes As String, _
ByVal bManualReset As Boolean, _
ByVal bInitialState As Boolean, _
ByVal lpName As String) As IntPtr

Public Declare Function SetEvent Lib "CoreDll.dll" (ByVal hEvent As IntPtr)
As Boolean

Public Sub FireEvent()

Dim ehandle As IntPtr = CreateEvent(Nothing, False, False,
"BackLightChangeEvent")

If (Not IsNothing(ehandle)) Then
SetEvent(ehandle)
End If
End Sub
 
I'm getting a number back. How do i know if it's valid or not? Should it be
positive or negative?? It's not zero.
 
SetEvent is a macro, so it's not callable. I'm surprised you're not getting
a MissingMethodException. Use EventModify
 
Chris,

I tried event modify. It still doesn't do anything. Doesn't this code look
right? I also tried it with the SDK prefix. Nothing seems to work. I'm
using a Dell Axim X50, PPC 2003.

Dim ehandle As IntPtr = CreateEvent(Nothing, False, False,
"BackLightChangeEvent")

EventModify(ehandle, 3)
 
And the value returned by CreateEvent() will be 0/NULL if there was a
problem creating the event. Anything other than 0 indicates that the event
was created.

Paul T.
 
Just out of curiosity, have you watched this code execute and made sure that
the EventModify call is actually *made*?

Another thing to try would be writing this little bit of code in C/C++ and
trying that. That would eliminate a whole class of problems and verify that
the event that you are firing is actually the *right one*.

Best I can tell, on ordinary Windows CE, the event name *is*
"BackLightChangeEvent."

Paul T.
 
Ok, the event is firing and it's working for setting the backlight timeout.
However, it isn't adjusting my brightness settings even though the registry
keys have changed. Any ideas here?

Sorry i don't know C or C++.
 
Sergey,

I really appreciate your post. I compiled your C# and ran it on my PPC. It
didn't change the brightness settings one bit. There must be some kind of
different event for the Dell Axim X50. I guess i'm just out of luck unless
someone else has any ideas.
 
Disd the same on smartphone 2003.
got same exception
Found this:

[Visual Basic]
Shared Public Function CreateEvent( _
ByVal Boolean bManualReset, _
ByVal Boolean bInitialState, _
ByVal String lpName _
) As IntPtr

Only 3 values in CreateEvent !

So I tried
----------------------------------------------------------------------------
Public Declare Function CreateEvent Lib "CoreDll.dll" ( _
ByVal bManualReset As Boolean, _
ByVal bInitialState As Boolean, _
ByVal lpName As String) As IntPtr

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr) As Boolean

Public Sub changeBacklight()

Dim ehandle = CreateEvent(False, False,
"BackLightChangeEvent")
CreateEvent(False, False, "BackLightChangeEvent")

If (Not IsNothing(ehandle)) Then
setevent(ehandle)
End If

End Sub
_______________________________________________________

But got the same exception
 
You have exception because of incorrect CreateEvent declaration. Check this:

<DllImport("coredll.dll")> Private Shared Function CreateEvent( _
ByVal lpEventAttributes As Integer,
ByVal bManualReset As
Integer, _
ByVal bInitialState As Integer, _
ByVal lpName As String) As
Integer

Also SetEvent is just an alias to EventModify function:

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr, ByVal function As IntPtr) As Integer


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Sergey do you have any ideas on how or what event to fire to tell the
operating system the brightness values have changed in the registry? I can
get the backlightevent to fire just fine and it updates the backlight timeout
but not the brightness values. I have no problem setting the values in the
registry I just don't konw how to tell it that they have changed. I have
tried everything even that SDKBackLightChangeEvent. Nothing makes a
difference. Any ideas?

Sergey Bogdanov said:
You have exception because of incorrect CreateEvent declaration. Check this:

<DllImport("coredll.dll")> Private Shared Function CreateEvent( _
ByVal lpEventAttributes As Integer,
ByVal bManualReset As
Integer, _
ByVal bInitialState As Integer, _
ByVal lpName As String) As
Integer

Also SetEvent is just an alias to EventModify function:

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr, ByVal function As IntPtr) As Integer


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Disd the same on smartphone 2003.
got same exception
Found this:

[Visual Basic]
Shared Public Function CreateEvent( _
ByVal Boolean bManualReset, _
ByVal Boolean bInitialState, _
ByVal String lpName _
) As IntPtr

Only 3 values in CreateEvent !

So I tried
----------------------------------------------------------------------------
Public Declare Function CreateEvent Lib "CoreDll.dll" ( _
ByVal bManualReset As Boolean, _
ByVal bInitialState As Boolean, _
ByVal lpName As String) As IntPtr

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr) As Boolean

Public Sub changeBacklight()

Dim ehandle = CreateEvent(False, False,
"BackLightChangeEvent")
CreateEvent(False, False, "BackLightChangeEvent")

If (Not IsNothing(ehandle)) Then
setevent(ehandle)
End If

End Sub
_______________________________________________________

But got the same exception
 
Are you sure that you changed the registry value correctly? Have you
seen your changes when opened the Settings->Backlight?

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Chris said:
Sergey do you have any ideas on how or what event to fire to tell the
operating system the brightness values have changed in the registry? I can
get the backlightevent to fire just fine and it updates the backlight timeout
but not the brightness values. I have no problem setting the values in the
registry I just don't konw how to tell it that they have changed. I have
tried everything even that SDKBackLightChangeEvent. Nothing makes a
difference. Any ideas?

:

You have exception because of incorrect CreateEvent declaration. Check this:

<DllImport("coredll.dll")> Private Shared Function CreateEvent( _
ByVal lpEventAttributes As Integer,
ByVal bManualReset As
Integer, _
ByVal bInitialState As Integer, _
ByVal lpName As String) As
Integer

Also SetEvent is just an alias to EventModify function:

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr, ByVal function As IntPtr) As Integer


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Disd the same on smartphone 2003.
got same exception
Found this:

[Visual Basic]
Shared Public Function CreateEvent( _
ByVal Boolean bManualReset, _
ByVal Boolean bInitialState, _
ByVal String lpName _
) As IntPtr

Only 3 values in CreateEvent !

So I tried
----------------------------------------------------------------------------
Public Declare Function CreateEvent Lib "CoreDll.dll" ( _
ByVal bManualReset As Boolean, _
ByVal bInitialState As Boolean, _
ByVal lpName As String) As IntPtr

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr) As Boolean

Public Sub changeBacklight()

Dim ehandle = CreateEvent(False, False,
"BackLightChangeEvent")
CreateEvent(False, False, "BackLightChangeEvent")

If (Not IsNothing(ehandle)) Then
setevent(ehandle)
End If

End Sub
_______________________________________________________

But got the same exception
 
I have a registry editor on my PPC and I can go in there and look at the
registry value. It has been changed to the value I set it to in my code.
However, i can't seem to inform the operating system the brightness has
changed. Those BackLight events have no effect on my Dell Axim X50.

Sergey Bogdanov said:
Are you sure that you changed the registry value correctly? Have you
seen your changes when opened the Settings->Backlight?

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Chris said:
Sergey do you have any ideas on how or what event to fire to tell the
operating system the brightness values have changed in the registry? I can
get the backlightevent to fire just fine and it updates the backlight timeout
but not the brightness values. I have no problem setting the values in the
registry I just don't konw how to tell it that they have changed. I have
tried everything even that SDKBackLightChangeEvent. Nothing makes a
difference. Any ideas?

:

You have exception because of incorrect CreateEvent declaration. Check this:

<DllImport("coredll.dll")> Private Shared Function CreateEvent( _
ByVal lpEventAttributes As Integer,
ByVal bManualReset As
Integer, _
ByVal bInitialState As Integer, _
ByVal lpName As String) As
Integer

Also SetEvent is just an alias to EventModify function:

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr, ByVal function As IntPtr) As Integer


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Dieter wrote:

Disd the same on smartphone 2003.
got same exception
Found this:

[Visual Basic]
Shared Public Function CreateEvent( _
ByVal Boolean bManualReset, _
ByVal Boolean bInitialState, _
ByVal String lpName _
) As IntPtr

Only 3 values in CreateEvent !

So I tried
----------------------------------------------------------------------------
Public Declare Function CreateEvent Lib "CoreDll.dll" ( _
ByVal bManualReset As Boolean, _
ByVal bInitialState As Boolean, _
ByVal lpName As String) As IntPtr

Public Declare Function setevent Lib "CoreDll.dll" (ByVal hEvent As
IntPtr) As Boolean

Public Sub changeBacklight()

Dim ehandle = CreateEvent(False, False,
"BackLightChangeEvent")
CreateEvent(False, False, "BackLightChangeEvent")

If (Not IsNothing(ehandle)) Then
setevent(ehandle)
End If

End Sub
_______________________________________________________

But got the same exception
 
Based on ur code in C# it works now:

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.
 
Chaning Brightness on Dell Axim x50

hi
Does anyone know how to change the brightness of the screen on Dell Axim x50 with Pocket PC 2003?

Thanks
~Durga
 
Back
Top