Change window style from bordered to borderless and back?

Windows specific forum
joske
User
User
Posts: 22
Joined: Thu Feb 09, 2006 8:12 pm
Location: Netherlands, Rotterdam

Change window style from bordered to borderless and back?

Post by joske »

Is it possible to change the style of a window from bordered to borderless and back while the program is running?
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post 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)
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post 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
Last edited by Hroudtwolf on Thu Mar 23, 2006 12:54 pm, edited 1 time in total.
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post 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:
joske
User
User
Posts: 22
Joined: Thu Feb 09, 2006 8:12 pm
Location: Netherlands, Rotterdam

Post by joske »

Yes! Thats it! :D

thanks Hroudtwolf!
Post Reply