Is it possible to hide the window Close Button?
Is it possible to hide the window Close Button?
Hi
I have single windowed application that should never be closed so I would like to remove the "Close" button from the Window's title bar. Is that possible and if so how?
Thanks,
Simon
I have single windowed application that should never be closed so I would like to remove the "Close" button from the Window's title bar. Is that possible and if so how?
Thanks,
Simon
Simon White
dCipher Computing
dCipher Computing
Re: Is it possible to hide the window Close Button?
Hi,
Don't use #PB_Window_SystemMenu as openwindows flag
Don't use #PB_Window_SystemMenu as openwindows flag
Code: Select all
If OpenWindow(0, 0, 0, 220, 100, "Exemple...", #PB_Window_ScreenCentered)
ButtonGadget (1, 10, 60, 200, 30, "Exit")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Ex = 1
EndSelect
EndSelect
Until EX = 1
EndIf
End
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1
Re: Is it possible to hide the window Close Button?
Hi
That works fine in Windows but I still have the close button in Linux.
Simon
That works fine in Windows but I still have the close button in Linux.
Simon
Simon White
dCipher Computing
dCipher Computing
Re: Is it possible to hide the window Close Button?
Have you already read this posting and tried the example?
Re: Is it possible to hide the window Close Button?
Hi
I had not read the post you suggested but have done so now and the close button is removed. However I have the Minimize and Maximize buttons showing which was not the case before I tried you code. So I would like to remove the Close, Minimize and Maximize buttons.
Thanks,
Simon
I had not read the post you suggested but have done so now and the close button is removed. However I have the Minimize and Maximize buttons showing which was not the case before I tried you code. So I would like to remove the Close, Minimize and Maximize buttons.
Thanks,
Simon
Simon White
dCipher Computing
dCipher Computing
Re: Is it possible to hide the window Close Button?
To help you any further it is essential to know your Linux distribution and your desktop environment because - as I have already remarked in my linked posting above - it depends on your desktop environment and window manager whether they allow manipulations of the titlebar. My posted example works fine in Linux Mint 19.3 'Tricia' with Cinnamon and doesn't display minimize and maximize buttons. Other window managers like Gnome 3, Xfce or LXDE do indeed display them together with the close symbol which may be removed.swhite wrote:However I have the Minimize and Maximize buttons showing which was not the case before I tried you code.
I don't have found a direct way to also remove the minimize and maximize buttons. But you may do another trick by overwriting your window's titlebar with a GtkHeaderBar containing only the window title. In this case GTK is in command and not the window manager of your distribution. The disadvantage is a title bar with an increased height because the GtkHeaderBar is a container which also may display a subtitle or other GTK widgets (of course also the minimize, maximize and close buttons). You may try the following example which only displays a centered title text. I tested it successfully on these distributions:swhite wrote:So I would like to remove the Close, Minimize and Maximize buttons.
- Linux Mint 19.3 x64 with Cinnamon (PB 5.46 x64 in ASCII and Unicode mode and PB 5.72 x64)
- Lubuntu 18.04 x86 with LXDE (PB 5.46 x86 in ASCII and Unicode mode and PB 5.72 x86)
- Ubuntu 18.04 x86 with Gnome 3 (PB 5.46 x86 in ASCII and Unicode mode and PB 5.72 x86)
- Ubuntu MATE 18.04 x86 with MATE (PB 5.46 x86 in ASCII and Unicode mode and PB 5.72 x86)
- Xubuntu 18.04 x86 with Xfce (PB 5.46 x86 in ASCII and Unicode mode and PB 5.72 x86)
Code: Select all
EnableExplicit
#HeaderBarTitle = "Close window with <Esc> key"
Import ""
gtk_header_bar_new()
gtk_header_bar_set_title(*HeaderBar, *Title)
gtk_window_set_titlebar(*Window.GtkWindow, *TitleBar.GtkWidget)
EndImport
Define HeaderBar.I
Define HeaderBarTitle.S = Space(StringByteLength(#HeaderBarTitle) + SizeOf(Integer))
Define WindowHeight.I
Define WindowWidth.I
Define WindowX.I
Define WindowY.I
OpenWindow(0, 100, 100, 320, 120, "Window with closing button",
#PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
ButtonGadget(0, 58, 40, 200, 25, "Remove all titlebar buttons")
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
If EventMenu() = 0
Break
EndIf
Case #PB_Event_Gadget
If EventGadget() = 0
WindowX = WindowX(0)
WindowY = WindowY(0)
WindowHeight = WindowHeight(0)
WindowWidth = WindowWidth(0)
HeaderBar = gtk_header_bar_new()
PokeS(@HeaderBarTitle, #HeaderBarTitle, -1, #PB_UTF8)
gtk_header_bar_set_title(HeaderBar, @HeaderBarTitle)
gtk_window_set_titlebar(WindowID(0), HeaderBar)
ResizeWindow(0, WindowX, WindowY, WindowWidth, WindowHeight)
gtk_widget_show_all_(WindowID(0))
DisableGadget(0, #True)
SetActiveWindow(0)
EndIf
EndSelect
ForEver
Re: Is it possible to hide the window Close Button?
I have modified my example from above to reduce the new titlebar's height (GtkHeaderBar) to that of PB's default titlebar height:
Code: Select all
EnableExplicit
#HeaderBarTitle = "Close window with <Esc> key"
#GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600
ImportC ""
gtk_css_provider_load_from_data (*CSSProvider, *CSSData, CSSDataLength.I,
*Error.GError)
gtk_css_provider_new()
gtk_style_context_add_provider_for_screen(*Screen.GdkScreen, *StyleProvider,
Priority.I)
gtk_header_bar_new()
gtk_header_bar_set_has_subtitle(*HeaderBar, Setting.L)
gtk_header_bar_set_title(*HeaderBar, Title.P-UTF8)
gtk_window_set_titlebar(*Window.GtkWindow, *TitleBar.GtkWidget)
EndImport
Define CSSProvider.I
Define *CSSStyle
Define Error.GError
Define HeaderBar.I
Define Screen.I
Define TitlebarHeight.I
Define WindowHeight.I
Define WindowWidth.I
Define WindowX.I
Define WindowY.I
OpenWindow(0, 100, 100, 320, 120, "Window with closing button",
#PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
ButtonGadget(0, 58, 40, 200, 25, "Remove all titlebar buttons")
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
If EventMenu() = 0
Break
EndIf
Case #PB_Event_Gadget
If EventGadget() = 0
WindowX = WindowX(0)
WindowY = WindowY(0)
WindowHeight = WindowHeight(0)
WindowWidth = WindowWidth(0)
TitlebarHeight = WindowHeight(0, #PB_Window_FrameCoordinate) +
0 - WindowHeight(0, #PB_Window_InnerCoordinate) - 2
; ----- Replace titlebar with GtkHeaderBar
HeaderBar = gtk_header_bar_new()
gtk_header_bar_set_has_subtitle(HeaderBar, #False)
gtk_header_bar_set_title(HeaderBar, #HeaderBarTitle)
gtk_window_set_titlebar(WindowID(0), HeaderBar)
ResizeWindow(0, WindowX, WindowY, WindowWidth, WindowHeight)
; ----- Reduce height of HeaderBar
CSSProvider = gtk_css_provider_new()
*CSSStyle = UTF8("headerbar {min-height: " + Str(TitlebarHeight) +
"px;}")
gtk_css_provider_load_from_data(CSSProvider, *CSSStyle,
MemorySize(*CSSStyle), @Error)
Screen = gdk_display_get_default_screen_(gdk_display_get_default_())
gtk_style_context_add_provider_for_screen(Screen, CSSProvider,
#GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
g_object_unref_(CSSProvider)
FreeMemory(*CSSStyle)
; ----- Display modified window
gtk_widget_show_all_(WindowID(0))
DisableGadget(0, #True)
SetActiveWindow(0)
EndIf
EndSelect
ForEver
Re: Is it possible to hide the window Close Button?
Hi
I am running XFCE on OpenSuse 15.1 with PB 5.72 64bit.
Simon
I am running XFCE on OpenSuse 15.1 with PB 5.72 64bit.
Simon
Simon White
dCipher Computing
dCipher Computing
Re: Is it possible to hide the window Close Button?
Thank you. But have you tried my last two examples? Theoretically they should run on all Linux distributions because they are not dependant on the window manager of your distribution anymore...swhite wrote:I am running XFCE on OpenSuse 15.1 with PB 5.72 64bit.
Re: Is it possible to hide the window Close Button?
Hi
Yes they both work perfectly.
Thanks,
Simon
Yes they both work perfectly.
Thanks,
Simon
Simon White
dCipher Computing
dCipher Computing