Code archives/Miscellaneous/Disable window Close button

This code has been declared by its author to be Public Domain code.

Download source code

Disable window Close button by Perturbatio2003
Requires the winapi decls for User32:

api_GetSystemMenu%(hWnd , bRevert):"GetSystemMenu"
api_DeleteMenu%(hMenuHandle, SC_CLOSE, MF_BYCOMMAND):"DeleteMenu"
AppTitle "testclose"
Graphics 640,480,32,2
SetBuffer BackBuffer()

Global hwndHandle%
Global hMenuHandle%
Const SC_CLOSE% = 61536
Const MF_BYCOMMAND% = 0

hwndHandle= api_FindWindow("Blitz Runtime Class", "testclose")

If hwndHandle<> 0 Then

	hMenuHandle= api_GetSystemMenu(hwndHandle, False);
	
	If hMenuHandle<> 0 Then
		api_DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND)	
	EndIf

EndIf


While Not KeyDown(1)
	Print hwndHandle
	Print hMenuHandle
	Flip
	Cls
Wend
End

Comments

jfk EO-111102006
great, and no dll required! thanks!


Code Archives Forum