Move a No-Border form by any thing!
No attachments for this post
To have a better UI, programmers usually use a borderless form. But there's no caption bar and the form cannot be move. This code help you to move a form by clicking anything that support mousemove, mouseup, mousedown events. See it , it's cool!
Original Author: Kenny Lai, Lai Ho Wa
Dim ism as boolean
Public Type POINTAPI
x As Long
y As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub lbltitle_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
ism = True
x1 = x + lblTitle.Left
y1 = y + lblTitle.Top
Private Sub lbltitle_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If ism = True Then
i = GetCursorPos(Pos)
x2 = Pos.x * Screen.TwipsPerPixelX
y2 = Pos.y * Screen.TwipsPerPixelY
Me.Move (x2 - x1), (y2 - y1)
Private Sub lbltitle_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Me.Top < 0 Then Me.Top = 0
If Me.Left < 0 Then Me.Left = 0
If Me.Top > (Screen.Height - (Me.Height / 10)) Then Me.Top = Screen.Height * 9 / 10
If Me.Left > (Screen.Width - (Me.Width / 10)) Then Me.Left = Screen.Width * 9 / 10
ism = False
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.