نقل قول: حرکت دادن فرم non border
Dim xx, yy
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
xx = X
yy = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Top = Me.Top + (Y - yy)
Me.Left = Me.Left + (X - xx)
End If
End Sub
این کد رو جایگزین کن
نقل قول: حرکت دادن فرم non border
سلام
یک روش کلی با استفاده از توابع API هست که در اکثر کاربردها موفق عمل میکنه.
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" ()
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Public Sub Mover(obj As Object)
On Error Resume Next
Call ReleaseCapture
SendMessage obj.hwnd, &HA1, 2, 0&
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbKeyLButton Then Mover Me
End Sub