Visual Basic Forum

Visual Basic Forum
für VB6 und VB.NET Programmierer
 
RegistrierenRegistrieren  LoginLogin
Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Fragen - Antworten
Autor
Nachricht
Teyhouse_
Poster
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
 
Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Fragen - Antworten

Tags: ausschalten, monitor, abschalten, sendmessage

 
 Verwandte Themen   Aufrufe   Letzter Beitrag 
Keine neuen Beiträge [suche] Tuturials winsock & daten senden 983 09.06.2011, 13:19
Keine neuen Beiträge [Video] *.dll & *.ocx Installer 2612 06.03.2008, 21:19
Keine neuen Beiträge ListView speichern & laden 1331 05.08.2008, 13:32
Keine neuen Beiträge Registry & Co Fragen 1203 03.05.2007, 10:57
Keine neuen Beiträge Listbox speichern & laden 2271 22.03.2007, 21:25
 


[ Time: 0.1173s ][ Queries: 82 (0.0583s) ][ GZIP on - Debug on ]