Pre zaujímavosť, kód pre zistenie handle MessageBoxu a jeho automatické zatvorenie
'Kód pre formulár
Private Declare Function SetTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Sub Command1_Click()
SetTimer Me.hwnd, NV_CLOSEMSGBOX, 5000, AddressOf TimerProc
MsgBox "Wait 5 sec!", vbOKOnly, "Close"
'Kód do modulu
Private Declare Function SetTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" ( _
ByVal hwnd As Long) As Long
Public Const NV_CLOSEMSGBOX As Long = &H5000&
Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal idEvent As Long, ByVal dwTime As Long)
Dim hMsgBox As Long
KillTimer hwnd, idEvent
If idEvent = NV_CLOSEMSGBOX Then
hMsgBox = FindWindow("#32770", "Close")
If hMsgBox Then
SetForegroundWindow hMsgBox
SendKeys "{enter}"
End If
End If
End Sub
.
|