设置父级 COM 和 WPF
我有两个屏幕。 一个是用 vb 创建的,第二个是用 WPF 创建的。
我必须将 vb 嵌入到 wpf 中。
因此我有一个想法,首先创建一个新的Windows Form窗体,并使用win32 API函数“SetParent”将vb屏幕嵌入到Windows窗体中。 其次,使用 wpf WindowsFormsHost 控件将 winform 托管在 wpf 表单内。
在单独的测试应用程序中一切都进展顺利。 但是当我尝试在完整的大型wpf应用程序中执行此操作时,winform加载为空,并且vb屏幕闪烁,然后立即消失。
有一些可能的解决方案吗???
请帮忙..真的很着急。
谢谢。
PS:如果有人有更好的方法将 vb6 嵌入到 wpf 中......我很想听听。
内里亚
I have two screens. one created in vb and the second is in WPF.
I must embed the vb inside the wpf.
Therefore i had an idea to firstly create a new Windows Form's form, and to use win32 API function "SetParent" in order to embed the vb screen inside the windows form.
Secondly, host the winform inside the wpf form using the wpf WindowsFormsHost control.
Everything is going just fine in an seperated test application.
but when i'm trying to do it in the complete huge wpf application, the winform is loaded empty, and the vb screen is flashes and then disappear immediately.
is there's some posible solution???
please help.. it's really rush.
Thanks.
P.S: if someone have better way to embed vb6 in wpf ... i whould like to hear it.
Neria
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是否可以将 VB6 屏幕公开为 ActiveX 控件? 如果是这样,添加导入 ActiveX 控件,然后将其添加到 WindowsFormsHost。 然后,您可以将
WindowsFormsHost
视为普通的 WPF 控件并将其添加到您的 WPF 应用程序中。Is is possible to expose the VB6 screen as an ActiveX control? If so, it would probably be cleaner to add import the ActiveX control, and then add it to an instance of WindowsFormsHost. You can then treat the
WindowsFormsHost
as a normal WPF control and add it to your WPF application.必须添加:
WindowsFormsHost?.Child = 新 System.Windows.Forms.Control
在使用 SetParent 传递 hWnd 之前
Must add:
WindowsFormsHost?.Child = New System.Windows.Forms.Control
before use SetParent to pass hWnd
您是否以编程方式启动 vb 应用程序? 如果是这样,您需要等待进程加载并为 vb-window 创建正确的窗口句柄。
WPF 窗口也必须首先初始化,然后尝试嵌入其他窗口。
您是否为子窗口(vb 窗口)设置了正确的大小?
如果您想查找窗口的句柄,请使用 FindWindow / FindWindowEx 或 WindowEnum。 如果您想对具有动态标题的窗口使用 FindWindow,您应该搜索类名称(希望只有一个窗口具有该名称)。
您是否为子项设置了 WS_Child 和 ~WS_Popup 样式?
are you starting the vb app programmatically? If so, you need to wait until the process will load and create the correct window handle for the vb-window.
The WPF window has also to be initialized first, then try to embed the other windows.
Have you set the correct size for the child (the vb window)?
If you want to find out the handle of a window use either FindWindow / FindWindowEx or WindowEnum. If you want to use FindWindow for a window that has a dynamic title you should search for the class name (hopefully there is only one window with it).
Have you set the styles WS_Child and ~WS_Popup for the child?