Hi
#PB_Window_BorderLess disables any #PB_Window_SizeGadget functionalities... so to say.
It's not implemented to have a frame-less window do any resizing, except the maximizing and restoring.
I want to create an owner-drawn windows frame but i do not know how to code a proper resizing job. I'd need to (1) change the mouse cursor and (2) resize and redraw the window content every mouse movement made. How to change the cursor?
Any help or even a workaround for this? Just wanted to toy with some owner-made frames.
Any chance to make a borderless window sizeable?
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Any chance to make a borderless window sizeable?
Code: Select all
sizewe = LoadCursor_(0, #IDC_SIZEWE)
sizeall = LoadCursor_(0, #IDC_SIZEALL)
sizenwse = LoadCursor_(0, #IDC_SIZENWSE)
sizenesw = LoadCursor_(0, #IDC_SIZENESW)
sizens = LoadCursor_(0, #IDC_SIZENS)
arrow = LoadCursor_(0, #IDC_ARROW)
OpenWindow(0,0,0,320,240,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
ButtonGadget(0, WindowWidth(0)/2-30, WindowHeight(0)-40, 60, 20, "Close")
quit = 0
Repeat
ev = WaitWindowEvent()
Select ev
Case #PB_Event_Gadget
quit = 1
Case #WM_SIZE
ResizeGadget(0, WindowWidth(0)/2-30, WindowHeight(0)-40, #PB_Ignore, #PB_Ignore)
Case #WM_MOUSEMOVE
x = WindowMouseX(0)
y = WindowMouseY(0)
If GetAsyncKeyState_(#VK_LBUTTON) & 32768 = 0
If y> 0 And y < 20
sizing = 7
SetCursor_(sizeall)
Else
sizing = 0
EndIf
If Not sizing
If WindowWidth(0)-x <= 6
If WindowHeight(0)-y <= 6 ; nwse
SetCursor_(sizenwse)
sizing = 3
Else ; we
SetCursor_(sizewe)
sizing = 2
EndIf
Else
sizing = 0
EndIf
EndIf
If Not sizing
If x <= 6
If WindowHeight(0)-y <= 6
SetCursor_(sizenesw)
sizing = 5
Else ; we
SetCursor_(sizewe)
sizing = 6
EndIf
Else
sizing = 0
EndIf
EndIf
If Not sizing
If WindowHeight(0)-y <= 6
If WindowWidth(0)-x <= 6 ; nwse
SetCursor_(sizenwse)
sizing = 3
ElseIf x <= 6
SetCursor_(sizenesw)
sizing = 5
Else ; ns
SetCursor_(sizens)
sizing = 4
EndIf
Else
sizing = 0
EndIf
EndIf
EndIf
If x < 0 Or y < 0
sizing = 0
SetCursor_(arrow)
SendMessage_(WindowID(0), #WM_LBUTTONUP, 0,0)
EndIf
Case #WM_LBUTTONDOWN
Select sizing
Case 2
SetCursor_(sizewe)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTRIGHT , #Null)
Case 3
SetCursor_(sizenwse)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTBOTTOMRIGHT , #Null)
Case 4
SetCursor_(sizens)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTBOTTOM , #Null)
Case 5
SetCursor_(sizenesw)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTBOTTOMLEFT , #Null)
Case 6
SetCursor_(sizewe)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTLEFT , #Null)
Case 7
SetCursor_(sizeall)
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION , #Null)
EndSelect
EndSelect
Until quit
Re: Any chance to make a borderless window sizeable?
This is a very beautiful code! Have so many thanks for that, Herr Vogel !!!! 


Re: Any chance to make a borderless window sizeable?
yes.
Code: Select all
;/---
;| Change sizability of a window
;|
;| don't need the Flag #PB_Window_SizeGadget on OpenWindow()
;|
;\-
Procedure SizableWindow(Window, State) ; State = #False or #True ..
Protected hwnd
hwnd = WindowID(Window)
If State ; == TRUE ------------------------------------------> add control
SetWindowLongPtr_(hwnd, #GWL_STYLE, GetWindowLongPtr_(hwnd, #GWL_STYLE) | #WS_THICKFRAME) :Debug "Sizable = ON "
Else ; == FALSE ---------------------------------------------> remove control
SetWindowLongPtr_(hwnd, #GWL_STYLE, GetWindowLongPtr_(hwnd, #GWL_STYLE) & ~#WS_THICKFRAME) :Debug "Sizable = OFF "
EndIf
SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndProcedure
If OpenWindow(0, 0, 0, 240, 120, "Sizable ... ", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
StickyWindow(0, 1) ; don't hide the window behind the IDE :)
ButtonGadget(1, 2, 4, 72, 20, "Quit")
ButtonGadget(2, 80, 4, 72, 20, "Sizeable", #PB_Button_Toggle)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow ; ALT+F4 works
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 1 ; button Quit
Break
Case 2 ; button Sizeable
SizableWindow(0, GetGadgetState(2)) ; <---
EndSelect
EndSelect
ForEver
EndIf
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Re: Any chance to make a borderless window sizeable?
And of course you can also do this directly.....
Code: Select all
OpenWindow(0, 0, 0, 240, 120, "Sizable ... ", #PB_Window_ScreenCentered | #PB_Window_BorderLess | #WS_THICKFRAME)
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).