这是我以前做的程序,你改改吧,加一个Image控件 '用户拖动开始 Private Sub imgSeperator_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then With imgSeperator picSeperator.Move .Left, .Top, .Width, .Height End With picSeperator.Visible = True picSeperator.Tag = "HasDraged" '表示以经有过拖动操作了 End IfEnd Sub '用户拖动中 Private Sub imgSeperator_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim sglPos As Single If Button = 1 Then sglPos = Y + imgSeperator.Top If sglPos < picHead.Height + M_PAIBAN_MIN_HEIGHT Then picSeperator.Top = picHead.Height + M_PAIBAN_MIN_HEIGHT ElseIf sglPos > picButton.Top - M_IMGSEPERATOR_HEIGHT Then picSeperator.Top = picButton.Top - M_IMGSEPERATOR_HEIGHT Else picSeperator.Top = sglPos End If End IfEnd Sub '用户拖动结束 Private Sub imgSeperator_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) picSeperator.Visible = False imgSeperator.Top = picSeperator.Top '恢复拖动柄 '按用户的要求对控件进行重排 picCurPaiban.Height = picSeperator.Top - picCurPaiban.Top Dim intPicPreHeight As Long intPicPreHeight = picButton.Top - picSeperator.Top - picSeperator.Height picPrePaiban.Move 0, picSeperator.Top + picSeperator.Height, picMain.Width, _ IIf(intPicPreHeight < 0, 0, intPicPreHeight)
picture1里面放一个picture2Dim xxPrivate Sub MDIForm_Load() With Picture2 .Appearance = 0 .BorderStyle = 0 .BackColor = &H8000000F .DragMode = 1 .MousePointer = 9 .Top = -10000 .Height = 100000 .Width = 50 .Left = Picture1.Width - 100 End With End SubPrivate Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single) Picture1.Width = xx Picture2.Left = Picture1.Width - 100 End SubPrivate Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer) xx = X End Sub Private Sub MDIForm_DragDrop(Source As Control, X As Single, Y As Single) Picture1.Width = xx Picture2.Left = Picture1.Width - 100 End SubPrivate Sub MDIForm_DragOver(Source As Control, X As Single, Y As Single, State As Integer) xx = X End Sub
你可以改用 activebar 2.x 控件
把picturebox 方放在最左边。问题是:怎么拖动改变大小。
不喜欢用多余的控件
对应鼠标坐标
'用户拖动开始
Private Sub imgSeperator_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
With imgSeperator
picSeperator.Move .Left, .Top, .Width, .Height
End With
picSeperator.Visible = True
picSeperator.Tag = "HasDraged" '表示以经有过拖动操作了
End IfEnd Sub
'用户拖动中
Private Sub imgSeperator_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sglPos As Single
If Button = 1 Then
sglPos = Y + imgSeperator.Top
If sglPos < picHead.Height + M_PAIBAN_MIN_HEIGHT Then
picSeperator.Top = picHead.Height + M_PAIBAN_MIN_HEIGHT
ElseIf sglPos > picButton.Top - M_IMGSEPERATOR_HEIGHT Then
picSeperator.Top = picButton.Top - M_IMGSEPERATOR_HEIGHT
Else
picSeperator.Top = sglPos
End If
End IfEnd Sub
'用户拖动结束
Private Sub imgSeperator_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
picSeperator.Visible = False
imgSeperator.Top = picSeperator.Top '恢复拖动柄
'按用户的要求对控件进行重排
picCurPaiban.Height = picSeperator.Top - picCurPaiban.Top
Dim intPicPreHeight As Long
intPicPreHeight = picButton.Top - picSeperator.Top - picSeperator.Height
picPrePaiban.Move 0, picSeperator.Top + picSeperator.Height, picMain.Width, _
IIf(intPicPreHeight < 0, 0, intPicPreHeight)
End Sub
错了,在mdi窗体里面我是改变鼠标的形状
不是用image
With Picture2
.Appearance = 0
.BorderStyle = 0
.BackColor = &H8000000F
.DragMode = 1
.MousePointer = 9
.Top = -10000
.Height = 100000
.Width = 50
.Left = Picture1.Width - 100
End With
End SubPrivate Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.Width = xx
Picture2.Left = Picture1.Width - 100
End SubPrivate Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
xx = X
End Sub
Private Sub MDIForm_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.Width = xx
Picture2.Left = Picture1.Width - 100
End SubPrivate Sub MDIForm_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
xx = X
End Sub