You can move a form which has no titlebar by 2 different methods. First method will not show any drag border while second method will show drag borders. |
Click here to copy the following block |
Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private bMoving As Boolean Private sngXStart As Single Private sngYStart As Single
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button <> 1 Then Exit Sub SetCapture Me.hwnd sngXStart = X sngYStart = Y bMoving = True End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Not bMoving Then Exit Sub Me.Move Me.Left - sngXStart + X, Me.Top - sngYStart + Y End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Not bMoving Then Exit Sub ReleaseCapture bMoving = False End Sub |
And here is the second approach to do the same thing |
Click here to copy the following block |
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Const WM_NCLBUTTONDOWN = &HA1 Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button <> 1 Then Exit Sub ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, _ HTCAPTION, 0&
bMoving = True End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Not bMoving Then Exit Sub
ReleaseCapture bMoving = False End Sub |
|