B
Benjamin Lukner
Hi!
I've found some eVC++ Code for turning the PocketPC display off and on.
Works fine, no problem.
URL:
http://www.microsoft.com/mobile/developer/technicalarticles/displayoff.asp
Now I try to do the same with VB.Net...
The code executes without any error, but the display stays on :-(
Normally it's either a problem with BYREF/BYVAL, the declared data type
or a misused parameter. (Sure, what else...)
Hope there's somebody who is familiar with C++ and VB and may have a
look at the code...
Thanks in advance!
Kind regards,
Benjamin Lukner
trinomix GmbH
Private Declare Function ExtEscape Lib "coredll.dll" ( _
ByVal hdc As Int32, _
ByVal nEscape As Int32, _
ByVal cbinput As Int32, _
ByVal lpszindata As Object, _
ByVal cbOutput As Int32, _
ByVal lpszOutData As Object _
) As Int32
Private Declare Function GetDC Lib "coredll.dll" ( _
ByVal hWnd As Int32 _
) As Int32
Private Declare Function ReleaseDC Lib "coredll.dll" ( _
ByVal hWnd As Int32, _
ByVal hDC As Int32 _
) As Int32
Private Declare Sub Sleep Lib "coredll.dll" ( _
ByVal dwMilliseconds As Int32 _
)
' GDI Escapes for ExtEscape()
Private Const QUERYESCSUPPORT As Int32 = 8
' The following are unique to CE
Private Const GETVFRAMEPHYSICAL As Int32 = 6144
Private Const GETVFRAMELEN As Int32 = 6145
Private Const DBGDRIVERSTAT As Int32 = 6146
Private Const SETPOWERMANAGEMENT As Int32 = 6147
Private Const GETPOWERMANAGEMENT As Int32 = 6148
Private Enum VIDEO_POWER_STATE As Long
VideoPowerOn = 1
VideoPowerStandBy = 2
VideoPowerSuspend = 3
VideoPowerOff = 4
End Enum
Private Structure VIDEO_POWER_MANAGEMENT
Dim Length As Int64
Dim DPMSVersion As Int64
Dim PowerState As Int64
End Structure
Public Sub TurnOffDisplay()
Dim gdc As Int32
Dim iESC As Int32 = SETPOWERMANAGEMENT
gdc = GetDC(Nothing)
If ExtEscape(gdc, QUERYESCSUPPORT, 4, iESC, 0, Nothing) = 0 Then
MsgBox("Sorry, your Pocket PC does not support DisplayOff", _
MsgBoxStyle.OKOnly, "Pocket PC Display Off Feature")
Else
Dim vpm As VIDEO_POWER_MANAGEMENT
vpm.Length = 24
vpm.DPMSVersion = 1
vpm.PowerState = VIDEO_POWER_STATE.VideoPowerOff
' Power off the display
ExtEscape(gdc, SETPOWERMANAGEMENT, 24, vpm, 0, Nothing)
Sleep(5000)
vpm.PowerState = VIDEO_POWER_STATE.VideoPowerOn
' Power on the display
ExtEscape(gdc, SETPOWERMANAGEMENT, 24, vpm, 0, Nothing)
ReleaseDC(Nothing, gdc)
End If
End Sub
I've found some eVC++ Code for turning the PocketPC display off and on.
Works fine, no problem.
URL:
http://www.microsoft.com/mobile/developer/technicalarticles/displayoff.asp
Now I try to do the same with VB.Net...
The code executes without any error, but the display stays on :-(
Normally it's either a problem with BYREF/BYVAL, the declared data type
or a misused parameter. (Sure, what else...)
Hope there's somebody who is familiar with C++ and VB and may have a
look at the code...
Thanks in advance!
Kind regards,
Benjamin Lukner
trinomix GmbH
Private Declare Function ExtEscape Lib "coredll.dll" ( _
ByVal hdc As Int32, _
ByVal nEscape As Int32, _
ByVal cbinput As Int32, _
ByVal lpszindata As Object, _
ByVal cbOutput As Int32, _
ByVal lpszOutData As Object _
) As Int32
Private Declare Function GetDC Lib "coredll.dll" ( _
ByVal hWnd As Int32 _
) As Int32
Private Declare Function ReleaseDC Lib "coredll.dll" ( _
ByVal hWnd As Int32, _
ByVal hDC As Int32 _
) As Int32
Private Declare Sub Sleep Lib "coredll.dll" ( _
ByVal dwMilliseconds As Int32 _
)
' GDI Escapes for ExtEscape()
Private Const QUERYESCSUPPORT As Int32 = 8
' The following are unique to CE
Private Const GETVFRAMEPHYSICAL As Int32 = 6144
Private Const GETVFRAMELEN As Int32 = 6145
Private Const DBGDRIVERSTAT As Int32 = 6146
Private Const SETPOWERMANAGEMENT As Int32 = 6147
Private Const GETPOWERMANAGEMENT As Int32 = 6148
Private Enum VIDEO_POWER_STATE As Long
VideoPowerOn = 1
VideoPowerStandBy = 2
VideoPowerSuspend = 3
VideoPowerOff = 4
End Enum
Private Structure VIDEO_POWER_MANAGEMENT
Dim Length As Int64
Dim DPMSVersion As Int64
Dim PowerState As Int64
End Structure
Public Sub TurnOffDisplay()
Dim gdc As Int32
Dim iESC As Int32 = SETPOWERMANAGEMENT
gdc = GetDC(Nothing)
If ExtEscape(gdc, QUERYESCSUPPORT, 4, iESC, 0, Nothing) = 0 Then
MsgBox("Sorry, your Pocket PC does not support DisplayOff", _
MsgBoxStyle.OKOnly, "Pocket PC Display Off Feature")
Else
Dim vpm As VIDEO_POWER_MANAGEMENT
vpm.Length = 24
vpm.DPMSVersion = 1
vpm.PowerState = VIDEO_POWER_STATE.VideoPowerOff
' Power off the display
ExtEscape(gdc, SETPOWERMANAGEMENT, 24, vpm, 0, Nothing)
Sleep(5000)
vpm.PowerState = VIDEO_POWER_STATE.VideoPowerOn
' Power on the display
ExtEscape(gdc, SETPOWERMANAGEMENT, 24, vpm, 0, Nothing)
ReleaseDC(Nothing, gdc)
End If
End Sub