Restored from previous forum. Originally posted by Franco.
Don't know if somebody else has posted such a thing...
Code: Select all
; (c) 2002 - Franco's template - absolutely freeware
; Procedure to disable the close button of your window.
; Needs the handle of the window
; Very useful for ChildWindows...
; Only your main Window can close your application :)
; Remember: If you make a 'GetSystemMenu_(WindowID,#TRUE)' API call
; after you call this Procedure you get the ExitMenuItem back!
; Than you have to remove it again...
; Remember: If you add your Items to a SysMenu you have to call this Procedure first.
; Otherwise you will remove your own Items (this Procedure counts from the back...)
Procedure DisableExitSysMenuItem(WindowID)
SysMenu = GetSystemMenu_(WindowID, #False) ;change to #True to re-enable
SysMenuItemCount = GetMenuItemCount_(SysMenu)
RemoveMenu_(SysMenu, SysMenuItemCount -1, #MF_DISABLED | #MF_BYPOSITION)
RemoveMenu_(SysMenu, SysMenuItemCount -2, #MF_DISABLED | #MF_BYPOSITION)
DrawMenuBar_(WindowID)
EndProcedure
OpenWindow(0, #PB_Any, #PB_Any, 200, 100, "Disable Close Button",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 30, 30, 140, 30, "Close Window Here")
DisableExitSysMenuItem(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
appQuit = 1
EndSelect
EndSelect
Until appQuit = 1
Franco
Sometimes you have to go a lonely way to accomplish genius things.