[RESOLVED] Move Fixed Border Form
Hi, I have a form which has a borderstyle of fixed single. I have removed the controlbox and set caption to nothing so that I don't have a title bar on my form.
How can I move around my form by clicking anywhere on the form and dragging it? Is this possible? Form.Move?
Thanks!
Re: Move Fixed Border Form
VB Code:
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long,
ByRef lParam As Any _
) As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Const WM_NCLBUTTONDOWN As Long = &HA1
Const HTCAPTION As Long = 2
If (Button And vbLeftButton) = vbLeftButton Then
ReleaseCapture
Call SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&)
End If
End Sub
Re: Move Fixed Border Form
try this:
VB Code:
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 Sub ReleaseCapture Lib "User32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Dim lngReturnValue As Long
If Button = 1 Then
'Release capture
Call ReleaseCapture
'Send a 'left mouse button down on caption'-message to our form
lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub
Private Sub Form_Paint()
Me.Print "Click on the form, hold the mouse button and drag it"
End Sub
Re: Move Fixed Border Form
Thanks guys, much appreciated. :thumb: