Postup:
V deklaraΦnφ Φßsti formulß°e zapiÜte:
Private
Type POINTAPI
x As Long
y As Long
End Type
Private Type MSGTYPE
hWnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Declare Function GetInputState Lib "user32" () As Long
Private Declare Function PeekMessage Lib "user32" Alias _
"PeekMessageA" (lpMsg As MSGTYPE, ByVal
hWnd As Long, _
ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As
Long, _
ByVal wRemoveMsg As Long) As Long
Private Const WM_KEYFIRST = &H100
Private Const WM_KEYLAST = &H108
Private Const PM_REMOVE = &H1
Public Function EscapePressed(Optional msgText As String) As Boolean
Dim mess As MSGTYPE
If GetInputState() Then
PeekMessage mess, 0, WM_KEYFIRST,
WM_KEYLAST, PM_REMOVE
If mess.wParam = vbKeyEscape Then
If Len(msgText)
= 0 Then
' Byla stisknuta klßvesa ESC, vrßtφ True bez dotazu
EscapePressed = True
Else
' Byla stisknuta klßvesa ESC, zobrazφ se dotaz
EscapePressed = (MsgBox(msgText, vbQuestion + vbYesNo) = vbYes)
End If
End If
End If
End Function
Funkce testuje
stisk klßvesy ESC a m∙₧e se dotßzat u₧ivatele na potvrzenφ stisku s
textem definovan²m pomocφ prom∞nnΘ msgText.
P°φklad pou₧itφ:
Do
'
Zpracovßvan² k≤d
If
EscapePressed("Opravdu si p°ejete p°eruÜit zpracovßvßnφ ?")
Then Exit Do
Loop
|