Page 1 of 1

Borderless window but taskbar behaves as normal?

Posted: Thu Jan 18, 2024 11:31 am
by Seymour Clufley
On Windows, the default behaviour is that clicking on an app in the taskbar will toggle the app's window size. If it is minimised, it will maximise. If it is maximised, it will minimise. With PB, in order to have this default behaviour, you need to add the minimise gadget:

Code: Select all

win = OpenWindow(#PB_Any,0,0,900,600, "test",#PB_Window_MinimizeGadget)
The issue I'm facing is that the window needs to be borderless - no titlebar, and therefore no minimise gadget. Is there any way to have a borderless window that has the default taskbar behaviour?

Re: Borderless window but taskbar behaves as normal?

Posted: Thu Jan 18, 2024 5:19 pm
by ChrisR
Seems to work by adding #WS_MINIMIZEBOX Style on the BorderLess Window:

Code: Select all

EnableExplicit

Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #Btn_1
EndEnumeration

Enumeration Shortcut
  #Shortcut_Escape = 3
EndEnumeration

If OpenWindow(#Window_0, 0, 0, 240, 140, "Title", #PB_Window_BorderLess)
  SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE) | #WS_MINIMIZEBOX)
  ButtonGadget(#Btn_1, 20, 20, 200, 100, "Button_1")
  AddKeyboardShortcut(#Window_0, #PB_Shortcut_Escape, #Shortcut_Escape)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_Menu And EventMenu() = #Shortcut_Escape
EndIf

Re: Borderless window but taskbar behaves as normal?

Posted: Thu Jan 18, 2024 8:39 pm
by Seymour Clufley
That's perfect, Chris. Thank you very much.

Re: Borderless window but taskbar behaves as normal?

Posted: Fri Jan 19, 2024 1:30 pm
by ChrisR
You're welcome, I could see the use for me too.
I had tried with PB_Event_ActivateWindow, ShowWindow_(hWnd, #SW_SHOWMINNOACTIVE),... but without any result.
On a second thought, this is indeed the solution here: it works as if the Minimize button were there (with its associated functions), but without displaying it.
And I wonder whether it should be a feature request ?
After all, the default behavior of the taskbar buttons should be the same whether the window is borderless or not.

Re: Borderless window but taskbar behaves as normal?

Posted: Fri Jan 19, 2024 7:40 pm
by Seymour Clufley
I agree, the taskbar button should behave consistently. And this behaviour is normal, so I'm sure most people would want it for their programs.

Re: Borderless window but taskbar behaves as normal?

Posted: Sat Jan 20, 2024 11:36 am
by charvista
Very interesting !

Re: Borderless window but taskbar behaves as normal?

Posted: Sun Jan 21, 2024 9:14 am
by Seymour Clufley
The feature request is here.