Page 1 of 1

How to restore borders on borderless windows?

Posted: Sat Aug 16, 2014 9:47 pm
by davido
If I choose to open a window with the #PB_Window_BorderLess flag, is there a way to restore the border during execution of the program at some point?
Preferably cross-platform, please.

Re: How to restore borders on borderless windows?

Posted: Sat Aug 16, 2014 10:10 pm
by RASHAD
Hi davido
I did the next snippet long time back
I hope it will be as you wished

F12 for toggle bet Border and No Border

Code: Select all

OpenWindow(0,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered|#PB_Window_MaximizeGadget)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE,GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_DLGFRAME)
SetWindowColor(0,#Gray)

Repeat
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
       
      
      Case #PB_Event_Gadget
            Select EventGadget()
             Case 1            
            EndSelect
             
      Case #WM_KEYDOWN
            Run ! 1
            If Run = 0 And EventwParam() = #PB_Shortcut_F12   ;F12 key
               SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_DLGFRAME)
               SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED| #SWP_DRAWFRAME| #SWP_NOMOVE| #SWP_NOSIZE| #SWP_NOZORDER)
            ElseIf Run = 1 And EventwParam() = #PB_Shortcut_F12
               SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) | #WS_DLGFRAME)
               SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED| #SWP_DRAWFRAME| #SWP_NOMOVE| #SWP_NOSIZE| #SWP_NOZORDER)
            EndIf
            
      Case #WM_LBUTTONDOWN
            If Run = 0
               SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
            EndIf
             
  EndSelect 

Until Quit = 1
End
# 2:
To avoid using EventwParam()

Code: Select all

OpenWindow(0,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered|#PB_Window_MaximizeGadget)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE,GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_DLGFRAME)
SetWindowColor(0,#Gray)

AddKeyboardShortcut(0, #PB_Shortcut_F12, 10)
Repeat
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
       
      
      Case #PB_Event_Gadget
            Select EventGadget()
             Case 1            
            EndSelect
            
      Case #PB_Event_Menu
             Select EventMenu()
                  Case 10
                          Run ! 1
                          If Run = 0
							               SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) &~ #WS_DLGFRAME)
							               SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED| #SWP_DRAWFRAME| #SWP_NOMOVE| #SWP_NOSIZE| #SWP_NOZORDER)
							            Else
							               SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) | #WS_DLGFRAME)
							               SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_FRAMECHANGED| #SWP_DRAWFRAME| #SWP_NOMOVE| #SWP_NOSIZE| #SWP_NOZORDER)
							            EndIf
						EndSelect
            
      Case #WM_LBUTTONDOWN
            If Run = 0
               SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
            EndIf
             
  EndSelect 

Until Quit = 1
End

Re: How to restore borders on borderless windows?

Posted: Sun Aug 17, 2014 6:08 am
by davido
Hi RASHAD,

Brilliant!
Thank you very much. :D
I've opted for the 2nd example as the manual indicates that EventwParam() is no longer supported.