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

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

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

Post 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.