如何从vb6 MSFlexGrid OLEDragDrop事件获取图像

发布于 2024-08-19 19:54:17 字数 852 浏览 8 评论 0原文

我有一个从 VB6 转换为 VB.NET 的 VB 项目。

在此,我有一个 MSFlexGrid 用作互操作兼容性。这意味着它在某种程度上转换为.NET,但在内部,许多机制仍然来自VB6/COM。

我需要从 PictureBox(.NET)中拖动图像并将其放在 Flexgrid 上。

这就是我初始化拖动的方法:

Private Sub picStartSymbol_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picStartSymbol.MouseDown
    picStartSymbol.DoDragDrop(picStartSymbol.Image, DragDropEffects.Copy)
End Sub

这就是我在 FlexGrid 中捕获拖放的位置:

Private Sub flxConstructionPoints_OLEDragDrop(ByVal sender As Object, ByVal e As AxMSFlexGridLib.DMSFlexGridEvents_OLEDragDropEvent) Handles flxConstructionPoints.OLEDragDrop

    Dim image As Image 
    Dim oleImage As Object
    oleImage = e.data.GetData(2) ''This gets an object of type 2 (bitmap)
    ''How to convert oleImage to a .NET Image?
End Sub

I have a VB project that is converted from VB6 to VB.NET.

In this, I have a MSFlexGrid that is used as an interop compatibiliy. That means it is somewhat converted to .NET, but internally, many of the mechanisms are still from VB6/COM.

I need to drag an image from a PictureBox (which is .NET) and drop it on the flexgrid.

This is what I do to initialize the drag:

Private Sub picStartSymbol_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picStartSymbol.MouseDown
    picStartSymbol.DoDragDrop(picStartSymbol.Image, DragDropEffects.Copy)
End Sub

And this is where I catch the drop in the FlexGrid:

Private Sub flxConstructionPoints_OLEDragDrop(ByVal sender As Object, ByVal e As AxMSFlexGridLib.DMSFlexGridEvents_OLEDragDropEvent) Handles flxConstructionPoints.OLEDragDrop

    Dim image As Image 
    Dim oleImage As Object
    oleImage = e.data.GetData(2) ''This gets an object of type 2 (bitmap)
    ''How to convert oleImage to a .NET Image?
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九命猫 2024-08-26 19:54:17

我不再有 VB6,所以我无法测试它,但尝试添加对 Microsoft.VisualBasic.Compatibility 然后调用:

Dim image as Image = Microsoft.VisualBasic.Compatibility.VB6.IPictureToImage(oleImage)

Dim image as Image = Microsoft.VisualBasic.Compatibility.VB6.IPictureDispToImage(oleImage)

I don't have VB6 anymore so I can't test this but try adding a reference to Microsoft.VisualBasic.Compatibility and then call:

Dim image as Image = Microsoft.VisualBasic.Compatibility.VB6.IPictureToImage(oleImage)

or

Dim image as Image = Microsoft.VisualBasic.Compatibility.VB6.IPictureDispToImage(oleImage)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文