Move a borderless window

I want to move a window without borders just by dragging it with the mouse. How can I do that?

OK I’ve done it just by adding these lines of code:

'Window MouseDown Event
mouse_x = System.MouseX - Me.Left
mouse_y = System.MouseY - Me.Top  
Return True

'Window MouseDrag Event
Me.Top = System.MouseY - mouse_y
Me.Left = System.MouseX - mouse_x

But I noticed that in Windows the dragging is more fluid than the Mac and Linux. Do you know why? And how can I solve this little issue?

Congratulations ! And this works for all windows :slight_smile:

My guess is that the window updates when Top is set and then again when Left is set.

Instead use the Bounds property to set both at once. You’ll want to get the bounds in MouseDown because it includes the title bar height.

[code]Property: dragBounds As REALbasic.Rect

Function MouseDown(X As Integer, Y As Integer) As Boolean
dragBounds = Bounds //store current bounds
mouse_x = x
mouse_y = y
return true
End Function

Sub MouseDrag(X As Integer, Y As Integer)
dragBounds.Left = dragBounds.Left + (X - mouse_x) //update by xy deltas
dragBounds.Top = dragBounds.Top + (Y - mouse_y)
Bounds = dragBounds //set
End Sub

what mouse_x and mouse_y are ?

[quote=67163:@luicano monti]Hi,
what mouse_x and mouse_y are ?[/quote]

Module level integer properties.