Monday, May 28, 2012

Fungsi Untuk Menjadikan Blank Layar Komputer

Di bawah ini merupakan fungsi untuk mematikan layar monitor.
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

Private Const
MONITOR_ON = -1&
Private Const MONITOR_LOWPOWER = 1&
Private Const MONITOR_OFF = 2&
Private Const SC_MONITORPOWER = &HF170&
Private Const WM_SYSCOMMAND = &H112

Public Function
TurnOnMonitor(hwnd As Long, bFlag As Boolean) As Boolean
If
bFlag Then
Call
SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_ON)
Else
Call
SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_OFF)
End If
End Function

Contoh penggunaan kode di atas:
Option Explicit 

Private Sub
Command1_Click()
TurnOnMonitor Me.hwnd, False
End Sub