CodeItBetter Programming Another VB Programming Blog

How to move a Form without Title bar

Posted on August 25, 2009

On some occasions, your client may ask you to use the form without title bar and however, he will ask you to make the form movable. As there is no title bar, we need to capture the move move, mouse up and mouse down events and move the form. So, here is the piece of code that will help you to accomplish that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Option Explicit
 
Dim OldX As Integer, OldY As Integer
Dim blnMove As Boolean
 
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  blnMove = True
  OldX = X
  OldY = Y
End Sub
 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If blnMove = True Then
    Me.Left = Me.Left + (X - OldX)
    Me.Top = Me.Top + (Y - OldY)
  End If
End Sub
 
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Me.Left = Me.Left + (X - OldX)
  Me.Top = Me.Top + (Y - OldY)
  blnMove = False
End Sub

Related posts:

  1. How to Move image with the mouse in a form
  2. How to move a form without a title bar
  3. How to allow Controls to move
  4. How to Move objects on a form at run time.
  5. How to Move a Form without using its Title Bar
  6. How to Drag/Move items from one List Box to another List Box
  7. How to Make your own Custom Title Bar
  8. How to move 3D Cube on form
  9. How to create a email link in your form
  10. How to select items in ListBox with right mouse button

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.