1. 모듈에 다음의 API 및 상수를 선언합니다.
Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Sub SetWindowPos Lib "user32" _
(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)
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Global Const SWP_NOACTIVATE = &H10
Global Const SWP_SHOWWINDOW = &H40
Public Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Integer, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hSrcDC As Integer, _
ByVal xSrc As Integer, _
ByVal ySrc As Integer, ByVal dwRop As Long) As Integer
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Const SRCCOPY = &HCC0020
Public Const SRCAND = &H8800C6
Public Const SRCINVERT = &H660046
Public Function WindowsDirectory() As String
Dim WinPath As String
Dim temp
WinPath = String(145, Chr(0))
temp = GetWindowsDirectory(WinPath, 145)
WindowsDirectory = Left(WinPath, InStr(WinPath, Chr(0)) - 1)
If Mid(WindowsDirectory, Len(WindowsDirectory)) = "\" Then Exit Function
WindowsDirectory = WindowsDirectory & "\"
End Function
2. 폼에 하나의 이미지(Image)콘트롤과 세개의 타이머콘트롤을 만들고 다음과 같이
코딩합니다.
◈ 타이머속성값 설정
첫번째 타이머 : Name - tmrOk
Enabled - False
Interval - 1000
두번째 타이머 : Name - tmrO
Enabled - False
Interval - 1000
세번째 타이머 : Name - TimerEnd
Enabled - False
Interval - 5000
Private Sub Form_Load()
On Error Resume Next
Width = Screen.Width
Height = Screen.Height
Top = 0
Left = 0
Err = 0
Image1.Picture = LoadPicture(WindowsDirectory() & "\logow.sys")
If Err <> 0 Then
MsgBox "윈도우 셧다운이미지가 없습니다.", vbExclamation
End
End If
Image1.Width = Width
Image1.Height = Height
Visible = False
MsgBox "확인을 클릭하면 윈도우를 셧다운합니다.", vbInformation
ShowCursor False ' 마우스커서를 감춘다.
tmrOk.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Hide
ShowCursor True ' 마우스커서를 보여준다.
End
End Sub
Private Sub TimerEnd_Timer()
SetWindowPos Me.hwnd, HWND_NOTOPMOST, Me.Left / 15, Me.Top / 15, Me.Width / 15, Me.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
Unload Me
TimerEnd.Enabled = False
End Sub
Private Sub tmrO_Timer()
Image1.Picture = LoadPicture(WindowsDirectory() & "\logos.sys")
tmrO.Enabled = False
TimerEnd.Enabled = True
End Sub
Private Sub tmrOk_Timer()
Visible = True
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / 15, Me.Top / 15, Me.Width / 15, Me.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
SetForegroundWindow hwnd
tmrO.Enabled = True
tmrOk.Enabled = False
End Sub
첫댓글 그림이 없어서 그런가.. 아무 현상도 일어나지 않은줄 알았는데 VB 개발툴상에 마우스 커서가 사라져 버렸네요. 어플 종료시켜도 말입니다.