How to know when player click on close icon??

Blitz3D Forums/Blitz3D Programming/How to know when player click on close icon??

Hi all,
There exist some way to know if the player has clicked on the exit icon of the game window?
I would like to do a fade after the player clicks on this icon and after that, launch a new window with a message.
Right now, when player press on exit icon the game just quit and I don't know of to do this from Blitz...

Could you please point me in the right direction?

Thanks in advance!

All the best.

You can use GetMessage/PeekMessage to read out what message was/is sent to the window. For this example, you need user32.decls declarations that are in the commented lines at the start of the code:
;.lib "user32.dll"
;
;api_GetMessage% (lpMsg*, hwnd%, wMsgFilterMin%, wMsgFilterMax%) : "GetMessageA"
;api_PeekMessage% (lpMsg*, hwnd%, wMsgFilterMin%, wMsgFilterMax%, wRemoveMsg%) : "PeekMessageA"
;

	;create temp. bank
	b = CreateBank(8 * 4)

	hwnd = SystemProperty$("apphwnd")

	Repeat
		
		;get incoming messages in range $10 to $10
		
		;api_PeekMessage(b, hwnd, $10, $10)
		api_PeekMessage(b, hwnd, $10, $10, 1)
	
		;hwnd sender	
		b1 = PeekInt(b, 0)
		;message number
		b2 = PeekInt(b, 4)
		;parameter 1
		b3 = PeekInt(b, 8)
		;parameter 2
		b4 = PeekInt(b, 16)
	
		;WM_CLOSE	
		If b2 And $10 = $10 Then Exit
		
		;some rnd number
		Cls
		Text 0, 0, Rand($FFFFFF)
		
	Forever
	
	FreeBank b
	
	Print "fading.."
	Delay 800
	
	RuntimeError "okay"
	
	End

You could also use BlitzClose.dll, from here:
http://www.blitzbasic.com/Community/posts.php?topic=44032

Impressive!!!
Thanks a lot b32! Thanks!!
:)
I'm very grateful.



All the best!