Restoring a borderless window from the taskbar

Windows specific forum
Seymour Clufley
Addict
Addict
Posts: 1233
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Restoring a borderless window from the taskbar

Post by Seymour Clufley »

Surprisingly, I can't find code on the forum for doing this.

I have a borderless window. A buttongadget enables the user to minimise it. That works. Pressing the window's taskbar button restores the window, as normal. But, if the window is currently restored, pressing the taskbar button does not minimise it. This does happen if I get rid of #PB_Window_Borderless and replace it with #PB_Window_MinimizeGadget - but I don't want to do that. The window needs to be borderless.

Does anyone know what to do?

Code: Select all

win = OpenWindow(#PB_Any,0,0,800,600,"Test",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
minbut = ButtonGadget(#PB_Any,50,50,100,25,"Minimise")

Macro MinimiseWindow
  ShowWindow_(WindowID(win),#SW_MINIMIZE)
  minimised = #True
  Debug "MINIMISED"
EndMacro

Macro RestoreWindow
  ShowWindow_(WindowID(win),#SW_SHOWNORMAL)
  minimised = #False
  Debug "RESTORED"
EndMacro


Repeat 
  we = WaitWindowEvent(50)
  Select we
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case minbut
          MinimiseWindow
      EndSelect
  EndSelect
Until GetAsyncKeyState_(#VK_ESCAPE)
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
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Restoring a borderless window from the taskbar

Post by RSBasic »

Code: Select all

win = OpenWindow(#PB_Any,0,0,800,600,"Test",#PB_Window_ScreenCentered|#PB_Window_BorderLess | #PB_Window_MinimizeGadget)
minbut = ButtonGadget(#PB_Any,50,50,100,25,"Minimise")

Macro MinimiseWindow
  ShowWindow_(WindowID(win),#SW_MINIMIZE)
  minimised = #True
  Debug "MINIMISED"
EndMacro

Macro RestoreWindow
  ShowWindow_(WindowID(win),#SW_SHOWNORMAL)
  minimised = #False
  Debug "RESTORED"
EndMacro

SetWindowLongPtr_(WindowID(win), #GWL_STYLE, GetWindowLongPtr_(WindowID(win), #GWL_STYLE) ! #WS_DLGFRAME)
SetWindowPos_(WindowID(win), 0,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE|#SWP_NOZORDER|#SWP_FRAMECHANGED)

Repeat
  we = WaitWindowEvent(50)
  Select we
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case minbut
          MinimiseWindow
      EndSelect
  EndSelect
Until GetAsyncKeyState_(#VK_ESCAPE)
Image
Image
Seymour Clufley
Addict
Addict
Posts: 1233
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Re: Restoring a borderless window from the taskbar

Post by Seymour Clufley »

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."
Post Reply