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.

Another way...

; ------------------------------------------------
; Disable windowed display's close button...
; ------------------------------------------------

; ------------------------------------------------
; ADD TO USER32.decls...
; ------------------------------------------------
; GetSystemMenu% (window, flags)
; EnableMenuItem% (menu, item, flags)
; ------------------------------------------------

; Parameters: Window handle, True/False...

Function DisableWindowClose (window, disable)
	EnableMenuItem (GetSystemMenu (window, 0), $F060, disable)
End Function

; Open windowed display...

Graphics3D 640, 480, 0, 2

; Get window handle immediately...

window = GetActiveWindow ()

; Turn off Close menu item/gadget...

DisableWindowClose (window, True)

; Set variable for toggle use below...

disable = True

Repeat

	Cls

	; Switch between enabled/disabled when Space is hit...
		
	If KeyHit (57)
		disable = 1 - disable
		DisableWindowClose (window, disable)
	EndIf
	
	Text 20, 20, "La la la (SPACE to toggle)..."

	Flip
	
Until KeyHit (1)

End