Borderless window but taskbar behaves as normal?

Just starting out? Need help? Post your questions and find answers here.
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Borderless window but taskbar behaves as normal?

Post 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?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Borderless window but taskbar behaves as normal?

Post 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
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Borderless window but taskbar behaves as normal?

Post by Seymour Clufley »

That's perfect, Chris. Thank you very much.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Borderless window but taskbar behaves as normal?

Post 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.
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Borderless window but taskbar behaves as normal?

Post 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.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Borderless window but taskbar behaves as normal?

Post by charvista »

Very interesting !
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Borderless window but taskbar behaves as normal?

Post by Seymour Clufley »

The feature request is here.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Post Reply