【问题标题】:How to drag and drop 2 different pictures in a form in VB6?VB6如何在一个表单中拖放2张不同的图片?
【发布时间】:2013-12-01 02:26:12
【问题描述】:

我正在研究如何在表单中拖放图片。现在,我可以拖放一张图片。但是,当有两张图片时,我不知道我会在代码中添加什么。

这是我的代码:

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    pic1.Move X, Y
End Sub

我的第二张照片的名称是“pic2”。因为当我尝试这段代码时:

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    pic1.Move X, Y
    pic2.move X, Y
End Sub

当我拖放两者中的任何一个时,显然它们会移动到相同的坐标。请帮忙。谢谢。

【问题讨论】:

  • 嗯,你正在移动两张图片,但不清楚你的问题出在哪里。你的问题是什么?你想让你的代码做什么?

标签: vb6 drag-and-drop


【解决方案1】:

您可以使用 Source 参数作为引发 DragDrop 事件的控件。下面的示例将移动 pic1 或 pic2 或任何其他 PictureBox 控件。

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)

    If TypeOf Source Is PictureBox Then
        Source.Move X, Y
    End If

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多