Dim a!, x1!, y1!Private Sub Frame1_MouseDown(frame As Integer, Shift As Integer, X As Single, Y As Single) x1 = X y1 = Y a = 1 End Sub Private Sub Frame1_MouseMove(frame As Integer, Shift As Integer, X As Single, Y As Single) If a = 1 Then Frame1.Left = (X - x1) + Frame1.Left Frame1.Top = (Y - y1) + Frame1.Top End If End Sub Private Sub Frame1_MouseUp(frame As Integer, Shift As Integer, X As Single, Y As Single) a = 0 End Sub
加个splitter 控件,分割好,加如要改尺寸的控件。 调整splitter时,修改控件的大小。
拖动控件的代码: Option ExplicitPrivate Declare Function ReleaseCapture Lib "user32" () As Long 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 Const HTCAPTION = 2 Const WM_NCLBUTTONDOWN = &HA1Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Dim ReturnVal As Long X = ReleaseCapture() ReturnVal = SendMessage(Command1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0) End If End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Dim ReturnVal As Long X = ReleaseCapture() ReturnVal = SendMessage(Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0) End If End Sub
x1 = X
y1 = Y
a = 1
End Sub
Private Sub Frame1_MouseMove(frame As Integer, Shift As Integer, X As Single, Y As Single)
If a = 1 Then
Frame1.Left = (X - x1) + Frame1.Left
Frame1.Top = (Y - y1) + Frame1.Top
End If
End Sub
Private Sub Frame1_MouseUp(frame As Integer, Shift As Integer, X As Single, Y As Single)
a = 0
End Sub
调整splitter时,修改控件的大小。
Option ExplicitPrivate Declare Function ReleaseCapture Lib "user32" () As Long
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
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(Command1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
楼主可以结帖了