问题: 容器中的控件(msflex)可能大于容器(scrbox)本身(或高于,或宽于),要求在容器内通过鼠标拖动移动控件进行浏览,移动过程中控件的内容必须呈显示状态并尽可能平滑,控件应最大可能保持在容器中(比如不能左边在控件之外,而右边已经向左离开容器的右侧).在线等待,解决问题,立即给分! (这里只能给100分,另帖给分)

解决方案 »

  1.   

    以下是一个在一个Picture1中移动Picture2的例子Option Explicit
    Dim OldX As Single, OldY As SinglePrivate Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        If Button And vbLeftButton Then OldX = X: OldY = Y
        
    End SubPrivate Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        If Button And vbLeftButton Then
            If Picture2.Top + Y - OldY > Picture1.Height - Picture2.Height And Picture2.Top + Y - OldY <= 0 Then Picture2.Move Picture2.Left, Picture2.Top + Y - OldY
            If Picture2.Left + X - OldX > Picture1.Width - Picture2.Width And Picture2.Left + X - OldX <= 0 Then Picture2.Move Picture2.Left + X - OldX
        End If
    End Sub