Hello,
How do you permit a client to move a form, with 'BorderStyle Property set to
none, in realtime? Any guideline on how to do this?
Thanks!
Sharrukin
Tom Esh - 29 Oct 2004 17:52 GMT
>How do you permit a client to move a form, with 'BorderStyle Property set to
>none, in realtime? Any guideline on how to do this?
Here's a popular method that works by using the Api to tell Windows a
mousedown has occurred on the titlebar. Works even if it has no
titlebar (providing you have not set the form's Moveable prop to
False).
'declaration section...
Private Const WM_NCLBUTTONDOWN = &HA1&
Private Const HTCAPTION = 2&
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
'code....
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
x As Single, y As Single)
If Button = vbLeftButton Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End If
End Sub
-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
J French - 30 Oct 2004 14:12 GMT
>Hello,
>
>How do you permit a client to move a form, with 'BorderStyle Property set to
>none, in realtime? Any guideline on how to do this?
Option Explicit
Private Declare Function ReleaseCapture _
Lib "user32" () As Long
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Any) As Integer
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Public Sub MoveObject(hwnd As Long)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
MoveObject Me.hwnd
End Sub