Closing the Window

Blitz3D Forums/Blitz3D Programming/Closing the Window

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Has anyone tried my solution above?

- Download the file here: raintree.hpg.com.br/blitzclose.dat
- Rename it to .zip (my host doesn't allow .zip files)
- Decompress and check readme.txt inside.

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")
                Exit ; Exit the program
	EndIf
Wend

UnInstallCloseHandler()


This way you can detect when either:
- The close button is pressed
- The user hs choosen close from system menu
- The user terminates the application from the task manager
- The user uses the Alt+F4 shortcut

Because all of this events send WM_CLOSE messages to the window.