Page 1 of 1

Default taskbar behavior for borderless windows

Posted: Fri Jan 19, 2024 4:21 pm
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

Re: Default taskbar behavior for borderless windows

Posted: Fri Jan 19, 2024 7:41 pm
by Seymour Clufley
+1

Re: Default taskbar behavior for borderless windows

Posted: Sun Jan 21, 2024 11:51 am
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)

Re: Default taskbar behavior for borderless windows

Posted: Sun Jan 21, 2024 12:31 pm
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:

Re: Default taskbar behavior for borderless windows

Posted: Sun Jan 21, 2024 2:40 pm
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.

Re: Default taskbar behavior for borderless windows

Posted: Sun Jan 21, 2024 7:08 pm
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

Re: Default taskbar behavior for borderless windows

Posted: Mon Jan 22, 2024 11:16 pm
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?