要实现的效果如下。
有两个IMAGE控件。A可见 B不可见。当鼠标在A上按下左键不放时,B移动到A所在的位置并可见,移动鼠标时,B移动 而A不移动,放开鼠标左键时B不可见,A出现在B所在位置。那位高人给我指点一下呀。本人将100相送!~~~~~~~~~谢谢啦~~

解决方案 »

  1.   

    Option ExplicitPrivate mbutton As IntegerPrivate Sub Form_Load()
        Image2.Visible = False
    End Sub
    Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        mbutton = Button
    End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        mbutton = 0
        Image2.Visible = False
        Image1.Move Image2.Left, Image2.Top
        
    End Sub
    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If mbutton = vbLeftButton Then
            Image2.Move Image1.Left + X, Image1.Top + Y
            Image2.Visible = True
        End If
    End Sub
      

  2.   

    Dim iPx As Integer, iPy As Integer
    Dim bb As Boolean 
    '把stop1改成你要拖动的控件名就行了Private Sub stop1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        bb = True
        iPx = X
        iPy = Y
        MousePointer = 5
    End SubPrivate Sub stop1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If bb Then
            stop1.Move stop1.Left + X - iPx, stop1.Top + Y - iPy
        End If
    End SubPrivate Sub stop1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        bb = False
        MousePointer = 0
    End Sub
      

  3.   

    真是,看了标题被误导了:
    [100分求]如何用鼠标拖动IMAGE控件平滑移动? 
                    ▲▲
      

  4.   

    呵呵,是的,你说描述的问题这与平滑移动有什么关系啊?我猜楼主是不是要实现模拟windows桌面上拖动图标的效果啊?(呵呵,猜测而已:)