如何从vb6 MSFlexGrid OLEDragDrop事件获取图像
我有一个从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不再有 VB6,所以我无法测试它,但尝试添加对 Microsoft.VisualBasic.Compatibility 然后调用:
或
I don't have VB6 anymore so I can't test this but try adding a reference to Microsoft.VisualBasic.Compatibility and then call:
or