Page 1 of 1

Tip: Disabling the X (exit button) on a window

Posted: Wed Jan 30, 2002 7:45 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

Just stick this somewhere between your OpenWindow code and main event loop.
Edited on 20 Sep 2002 to do it the "proper" way. :)

Code: Select all

r=GetMenuItemCount_(GetSystemMenu_(WindowID(),#FALSE)) ; Get number of menu items.
RemoveMenu_(GetSystemMenu_(WindowID(),0),r-1,#MF_BYPOSITION) ; Disable "X" button.
RemoveMenu_(GetSystemMenu_(WindowID(),0),r-2,#MF_BYPOSITION) ; Remove separator.
DrawMenuBar_(WindowID()) ; Redraw the window's menu bar to reflect the changes.
PB - Registered PureBasic Coder

Edited again on 21 Jan 2006 to include the keyword: close.