Blitz Close
Tweet dll windows toolbox
DLL to detect close button event (C++ source)
Author: Marcelo
; Example code (need the DLL above)
AppTitle "test123"
; First parameter is the scancode to fake, the second is the window name
InstallCloseHandler(57, "test123")
While (Not KeyHit(1))
; This if will be TRUE when the user tries to close the window, usually don't use a common key
If KeyHit(57)
DebugLog("yeah")
EndIf
Wend
UnInstallCloseHandler()
Another example using the win32 api messagebox when hitting the escape key (1) or closing the window..
AppTitle "My Game"
; First parameter is the scancode to fake, the second is the window name
InstallCloseHandler(148, "My Game") ; Map to a least used key
MB_ICONASTERISK = $20
MB_OKCANCEL = $1
Repeat
Cls
; This if will be TRUE when the user tries to close the window, usually don't use a common key
If KeyHit(1) Or KeyHit(148)
result = api_MessageBox(0, "Are you sure you want to exit?", "Exit Game", MB_ICONASTERISK + MB_OKCANCEL )
If result = 1 Then End
EndIf
Flip
Forever
UnInstallCloseHandler()
End
Reply To Topic (minimum 10 characters)
Please log in to reply