How to move a borderless window?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
you can 'fake a drag on the captionbar' by putting the following into your window callback procedure:
you could of course easily extend this to only work when a certain region of you window has been clicked...
you can 'fake a drag on the captionbar' by putting the following into your window callback procedure:
Code: Select all
If Msg=#WM_LBUTTONDOWN ;mousebutton clicked...
; fool windows telling that the user is
; actually dragging the application caption bar
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
lParam holds the mouse coordinates
you could test if the mouse is in the desired part of your window and only then do the sendmessage_() thingy
lParam holds the mouse coordinates
Code: Select all
mouse_x.w = lParam ; x-coord
mouse_y.w = lParam >> 16 ; y-coord
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by traumatic.
i made a small example for you (there are always different ways to do this of course):
this will only allow dragging on the upper 60 px. (my > 16
If (my < 60)
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
ProcedureReturn DefWindowProc_(hWnd, Msg, wParam, lParam)
EndProcedure
hWnd = OpenWindow(0, 0, 0, 320, 240, #PB_Window_Borderless, "test4merendo")
SetWindowCallback(@WndProc())
Repeat
If PeekMessage_(@WndProcMsg, 0, 0, 0, #PM_REMOVE) ; check if there is a message for this window
If WndProcMsg = #WM_QUIT : EndIf
; else translate and dispatch the message to this window
TranslateMessage_(@WndProcMsg)
DispatchMessage_(@WndProcMsg)
EndIf
ForEver
[/code]
i made a small example for you (there are always different ways to do this of course):
this will only allow dragging on the upper 60 px. (my > 16
If (my < 60)
SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
ProcedureReturn DefWindowProc_(hWnd, Msg, wParam, lParam)
EndProcedure
hWnd = OpenWindow(0, 0, 0, 320, 240, #PB_Window_Borderless, "test4merendo")
SetWindowCallback(@WndProc())
Repeat
If PeekMessage_(@WndProcMsg, 0, 0, 0, #PM_REMOVE) ; check if there is a message for this window
If WndProcMsg = #WM_QUIT : EndIf
; else translate and dispatch the message to this window
TranslateMessage_(@WndProcMsg)
DispatchMessage_(@WndProcMsg)
EndIf
ForEver
[/code]
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by merendo.
Well, i've made it a little differently...
Procedure MoveCallBack(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
mouse_x.w = lParam ; x-coord
mouse_y.w = lParam >> 16 ; y-coord
If mouse_x.w > 0 And mouse_x.w 255 And mouse_y.w < 300
conditionsdone = 1 ; Test if the mouse is inside the right region. If so, allow to move the window (vari conditionsdone)
Else
conditionsdone = 0
EndIf
If Message=#WM_LBUTTONDOWN And conditionsdone ;mousebutton clicked... and check if the vari allows to move...
; fool windows telling that the user is
; actually dragging the application caption bar
SendMessage_(WindowID, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
ProcedureReturn Result
EndProcedure
Cu @ll, merendo
--
I've been hiding - What am I hiding from???
Well, i've made it a little differently...
Procedure MoveCallBack(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
mouse_x.w = lParam ; x-coord
mouse_y.w = lParam >> 16 ; y-coord
If mouse_x.w > 0 And mouse_x.w 255 And mouse_y.w < 300
conditionsdone = 1 ; Test if the mouse is inside the right region. If so, allow to move the window (vari conditionsdone)
Else
conditionsdone = 0
EndIf
If Message=#WM_LBUTTONDOWN And conditionsdone ;mousebutton clicked... and check if the vari allows to move...
; fool windows telling that the user is
; actually dragging the application caption bar
SendMessage_(WindowID, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
ProcedureReturn Result
EndProcedure
Cu @ll, merendo
--
I've been hiding - What am I hiding from???
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Or you could save yourself some typing and NOT pu t it in a callback...
Or you could save yourself some typing and NOT pu t it in a callback...
Code: Select all
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_CloseWindow
quit=1
Case #WM_LBUTTONDOWN
ReleaseCapture_()
SendMessage_(hWnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
EndSelect
Until quit=1
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm