0
votes

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

3

3 Answers

1
votes

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.

0
votes

Must add: WindowsFormsHost?.Child = New System.Windows.Forms.Control before use SetParent to pass hWnd

0
votes

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?