Page 1 of 1

Change window style from bordered to borderless and back?

Posted: Wed Mar 22, 2006 12:04 pm
by joske
Is it possible to change the style of a window from bordered to borderless and back while the program is running?

Posted: Wed Mar 22, 2006 10:37 pm
by Kaiser
It is, I think it's using the Windows API... after all, Visual Designer does it in runtime so it's possible (but kinda buggy, or so I noticed when messing around with VD)

Posted: Thu Mar 23, 2006 3:53 am
by Hroudtwolf
Maybe, this should help.

Code: Select all

; 2006 Hroudtwolf
; PB 4.00


If OpenWindow(0, 0, 0, 200, 200, "Remove windowstyle", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #WS_BORDER) And CreateGadgetList(WindowID(0))
  ButtonGadget(0, 10, 10, 180, 20, "No Border")
  ButtonGadget(1, 10, 40, 180, 20, "Border")

  Repeat 
     Event.l=WaitWindowEvent()
     If Event.l=#PB_Event_Gadget
       HideWindow (0,1)
       If EventGadget()=0
          SetWindowLong_(WindowID(0),#GWL_STYLE,GetWindowLong_(WindowID(0),#GWL_STYLE)& ~#WS_BORDER)
       ElseIf EventGadget()=1
          SetWindowLong_(WindowID(0),#GWL_STYLE,GetWindowLong_(WindowID(0),#GWL_STYLE)|#WS_BORDER)
       EndIf 
       HideWindow (0,0)
     EndIf 
  Until Event = #PB_Event_CloseWindow
EndIf

Posted: Thu Mar 23, 2006 12:12 pm
by Baldrick
Tiny little mistake in Hroudtwolf's speed written code.

Until WaitWindowEvent() = #PB_Event_CloseWindow
think you meant
Until Event = #PB_Event_CloseWindow
:wink:

Posted: Thu Mar 23, 2006 4:56 pm
by joske
Yes! Thats it! :D

thanks Hroudtwolf!