|
| Autor |
Nachricht |
Teyhouse_ Poster


Anmeldedatum: 11.02.2007 Beiträge: 100
|
Monitor Ausschalten
Verfasst am: 10.09.2008, 22:10 |
|
|
Habe da nen Problem mit dem Ausschalten des Monitores.. der Monitor schaltet sich irgendwie nur ne Sekunde oder so ab... aber bleibt net aus...?
Hier mal der Code:
[code]Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Any) As Long
'Update am 6. April 2003: der Monitor sollte sich nun auch
'unter Windows 2k/XP abschalten
Const WM_SYSCOMMAND = &H112&
Const SC_MONITORPOWER = &HF170&
' Deklaration:
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_SHOWWINDOW = &H40
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub SetWinPos(frmForm As Form, bolSetToForeground As Boolean)
If bolSetToForeground = True Then
Call SetWindowPos(frmForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
Else
Call SetWindowPos(frmForm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 2&
If KeyAscii = 35 Then SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal -1&
'35 - Raute
'43 - Plus
End Sub
Private Sub Form_Load()
Form1.Visible = False
Call SetWinPos(Me, True)
End Sub[/code]
Mfg.
Teyhouse |
|
| |
|
 |
|
|