Home » Coding Basics » How to move a Form without Title bar
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:
- How to Move image with the mouse in a form
- How to move a form without a title bar
- How to allow Controls to move
- How to Drag/Move items from one List Box to another List Box
- How to Move objects on a form at run time.
- How to Move a Form without using its Title Bar
- How to Make your own Custom Title Bar
- How to create a email link in your form
- How to move 3D Cube on form
- How to select portion of Picture and paste it to Picture Box
Enjoy this article?
Filed under: Coding Basics, Controls
Leave a comment
Sponsors
Link Back to us
Donations
If you are benefited from this site, please donate a small contribution to us. It will help to maintain this site better.