Default taskbar behavior for borderless windows

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Default taskbar behavior for borderless windows

Post by ChrisR »

See: Borderless window but taskbar behaves as normal?

I think it would be good to natively have the same default taskbar behavior for borderless windows like for all other windows.
Or in an other way, for borderless windows, it's currently strange not to have the same behavior as other windows.

Adding the #WS_MINIMIZEBOX style after creating the borderless window is enough.
And for those who don't want to take advantage of the default taskbar behavior, they can easily remove the style:
SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, GetWindowLongPtr_(WindowID(Window), #GWL_STYLE) &~ #WS_MINIMIZEBOX)

Example with or without default taskbar behavior

Code: Select all

If OpenWindow(0, 0, 0, 260, 180, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
  AddKeyboardShortcut(0, #PB_Shortcut_Escape, 1)
  ButtonGadget(0, 20, 20, 220, 100, "Add Minimize Box", #PB_Button_Toggle)
  TextGadget(1, 20, 130, 220, 40, "Borderless window does not use the default taskbar buttons behavior", #PB_Text_Center)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
      Case #PB_Event_Menu
        If EventMenu() = 1
          Break
        EndIf
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            If GetGadgetState(0)
              SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) | #WS_MINIMIZEBOX)
              SetGadgetText(0, "Remove Minimize Box")
              SetGadgetText(1, "Borderless window using default taskbar button behavior ")
            Else
              SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_MINIMIZEBOX)
              SetGadgetText(0, "Add Minimize Box")
              SetGadgetText(1, "Borderless window does not use the default taskbar buttons behavior")
            EndIf
        EndSelect
    EndSelect
  ForEver
EndIf
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Default taskbar behavior for borderless windows

Post by Seymour Clufley »

+1
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: Default taskbar behavior for borderless windows

Post by charvista »

+1

I second that nice idea, especially useful on touch screens, but keep in mind that the taskbar can be hidden... (if one has set Windows' taskbar to hide it automatically)
- 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%
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Default taskbar behavior for borderless windows

Post by ChrisR »

Even with the hidden taskbar, the behavior would remain identical for borderless windows, buttons would be hidden :D
It shouldn't be much to implement for Fred, just add the #WS_MINIMIZEBOX style after creating the borderless window.
I hope it will be added, small details sometimes make all the difference :wink:
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Default taskbar behavior for borderless windows

Post by freak »

There are a lot of uses for borderless windows where a taskbar button is not desired. For example the AutoComplete window in the IDE.
quidquid Latine dictum sit altum videtur
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Default taskbar behavior for borderless windows

Post by ChrisR »

freak wrote: Sun Jan 21, 2024 2:40 pm There are a lot of uses for borderless windows where a taskbar button is not desired. For example the AutoComplete window in the IDE.
Yes of course, but that's not the point here :!:

The request is not about whether or not to display the taskbar button.
It is to have the default taskbar behavior, for borderless windows, when (if) the button is displayed in this taskbar.

If there is No taskbar button for a borderless window, Adding #WS_MINIMIZEBOX style does not change at All the window's behavior, there will still be no taskbar button and it is not possible to minimize it. No change here

On the other hand, it does make a difference, for a borderless window With a taskbar button. Adding #WS_MINIMIZEBOX style enables the default taskbar behavior as for other taskbar buttons.

Default taskbar behavior: If you click on a taskbar button and the window is displayed, it will be minimized.
And inversely, if it is minimized, it will be redisplayed with the same previous size.
But for this you need to have a taskbar button.

Change the #Window_With_TaskBar_Button constant (#True | #False) to see, with or without taskbar button:

Code: Select all

#Window_With_TaskBar_Button = #False   ; #True | #False

CompilerIf #Window_With_TaskBar_Button
  OpenWindow(0, 100, 100, 260, 180, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
  AddKeyboardShortcut(0, #PB_Shortcut_Escape, 1)
CompilerElse
  OpenWindow(0, -10, -10, 0, 0, "Fake Parent", #PB_Window_Invisible)
  OpenWindow(1, 500, 100, 260, 180, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered, WindowID(0))
  AddKeyboardShortcut(1, #PB_Shortcut_Escape, 1)
CompilerEndIf

ButtonGadget(0, 20, 20, 220, 80, "Add Minimize Box", #PB_Button_Toggle)
TextGadget(1, 20, 100, 220, 60, "Borderless window does not use the default taskbar buttons behavior." + #CRLF$+ "If there is a Taskbar Button!", #PB_Text_Center)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow, #WM_CLOSE
      Break
    Case #PB_Event_Menu
      If EventMenu() = 1
        Break
      EndIf
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          If GetGadgetState(0)
            SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) | #WS_MINIMIZEBOX)
            SetGadgetText(0, "Remove Minimize Box")
            SetGadgetText(1, "Borderless window using default taskbar button behavior." + #CRLF$+ " If there is a Taskbar Button!")
          Else
            SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_MINIMIZEBOX)
            SetGadgetText(0, "Add Minimize Box")
            SetGadgetText(1, "Borderless window does not use the default taskbar buttons behavior." + #CRLF$+ "If there is a Taskbar Button!")
          EndIf
      EndSelect
  EndSelect
ForEver
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Default taskbar behavior for borderless windows

Post by Seymour Clufley »

freak wrote: Sun Jan 21, 2024 2:40 pm There are a lot of uses for borderless windows where a taskbar button is not desired. For example the AutoComplete window in the IDE.
Sure, but what's the point of having a taskbar button, but it doesn't work in the normal way? Wouldn't it be better to either have a taskbar button or not have it?
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