我这个是实现上下拖动的 你看下 Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) With Image1 Picture1.Move .Left, .Top, .Width, .Height / 2 End With Picture1.Visible = True mbMoving = True End SubPrivate Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Dim sglPos As Single If mbMoving Then sglPos = y + Image1.Top If sglPos < sglSplitLimit Then Picture1.Top = sglSplitLimit ElseIf sglPos > Me.Height - sglSplitLimit Then Picture1.Top = Me.Height - sglSplitLimit Else Picture1.Top = sglPos End If End If End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) SizeControls Picture1.Top Picture1.Visible = False mbMoving = False End Sub Sub SizeControls(x As Single) On Error Resume Next If x < 1000 Then x = 1000 If x > Me.Height - 1500 - Toolbar.Height Then x = Me.Height - 1500 + Toolbar.Height ListView1.Height = x - Toolbar.Height Image1.Top = x ListView2.Top = x + 140 ListView2.Height = Me.Height - (ListView1.Height + Image1.Height + 400) - Toolbar.Height ListView1.Width = Me.Width - 100 ListView2.Width = Me.Width - 100 Image1.Width = Me.Width - 100 End Sub
你看下
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
With Image1
Picture1.Move .Left, .Top, .Width, .Height / 2
End With
Picture1.Visible = True
mbMoving = True
End SubPrivate Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim sglPos As Single
If mbMoving Then
sglPos = y + Image1.Top
If sglPos < sglSplitLimit Then
Picture1.Top = sglSplitLimit
ElseIf sglPos > Me.Height - sglSplitLimit Then
Picture1.Top = Me.Height - sglSplitLimit
Else
Picture1.Top = sglPos
End If
End If
End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
SizeControls Picture1.Top
Picture1.Visible = False
mbMoving = False
End Sub
Sub SizeControls(x As Single)
On Error Resume Next
If x < 1000 Then x = 1000
If x > Me.Height - 1500 - Toolbar.Height Then x = Me.Height - 1500 + Toolbar.Height
ListView1.Height = x - Toolbar.Height
Image1.Top = x
ListView2.Top = x + 140
ListView2.Height = Me.Height - (ListView1.Height + Image1.Height + 400) - Toolbar.Height ListView1.Width = Me.Width - 100
ListView2.Width = Me.Width - 100
Image1.Width = Me.Width - 100
End Sub