Titlebar and system-icons

Just starting out? Need help? Post your questions and find answers here.
Garfield9992003
User
User
Posts: 15
Joined: Tue Apr 26, 2005 8:13 am

Titlebar and system-icons

Post by Garfield9992003 »

Hi.

How can I disable the systemmenu and all icons - except the minimize-button from titlebar in a window?

My program run in systray and the user should only minimize the window.

Frank
ebs
Enthusiast
Enthusiast
Posts: 557
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Frank,

You can enable/disable the Minimize and Maximize buttons using the #PB_Window_MinimizeGadget and #PB_Window_MaximizeGadget constants in the OpenWindow() function. If you want to disable the Close button too, you can call this procedure, passing it the Window identifier.

Code: Select all

Procedure DisableCloseButton(Window.l)
  ; get handle to window's system menu
  hMenu.l = GetSystemMenu_(WindowID(Window), 0)
  If hMenu  
    ; get number of items in the menu
    menuItemCount.l = GetMenuItemCount_(hMenu)
   
    ; remove system menu Close menu item
    ; menu item is 0-based, so the last
    ; item on the menu is menuItemCount - 1
    RemoveMenu_(hMenu, menuItemCount - 1, #MF_REMOVE|#MF_BYPOSITION)
    
    ; remove system menu separator line
    RemoveMenu_(hMenu, menuItemCount - 2, #MF_REMOVE|#MF_BYPOSITION)
    
    ; force a redraw of the menu, to
    ; refresh the titlebar, dimming the X
    DrawMenuBar_(WindowID(Window))
  EndIf
EndProcedure
Regards,
Eric
Post Reply