How to know when player click on close icon??

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

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.

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