VB6 ActiveX Control Inside WPF With Scrollbars - wpf

I have some legacy VB6, which I am hosting inside an ActiveX control, which is in my WPF application.
Despite putting the control inside of a DockPanel, which is inside a ScrollViewer, the VB6 displays outside the bounds of both, sitting on top of the rest of the application.
Does anyone know how I can keep the VB6 inside of the ScrollViewer without it spilling out onto the rest of the application?
ScrollViewer - expands to fill an area
Has a child element...
DockPanel - fixed to the height and width of the VB6 form
Has a child element...
VB6
Any help or guidance will be greatly appreciated.

I don't think you can do this, the ActiveX control is just going to sit on top of any XAML you wrap it in. As a workaround you could try creating a control in WinForms that contains your ActiveX control and handles the scrolling, then embed that in the WPF app. It's a bit hacky, and might be a pain if you need to resize, but it SHOULD work :-)

Related

Moving (dragging) HwndHost using mouse

Here's what I am trying to accomplish - To create an MDI application in WPF, which can host child web applications. I am using WPF webbrowser control to render web applications. WPF inherently doesn't seem to support MDI applications, so after a bit of searching, I found this project, which uses UI controls to simulate windows and manages them inside a WPF canvas. This approach seems to work reasonably well until I start adding webbrowser control object as an MDI child.
When I add webbrowser control as an MDI child, it always appears on top of other WPF elements including other MDI child controls (as shown below). From what I understand, webbrowser control always appears on top of any other WPF object except for window (and popup). Assuming that's true, I think I need to use actual WPF window to avoid overlapping issue.
The only solution i can think of right now is to wrap WPF window inside an HwndHost object and then add that as an MDI child. However it appears that a child window cannot have title bar. That means that i need to have a window that has a dummy title bar area (just like actual window title bar) and actual content area (which will show webbrowser control) as shown below (Red border is HwndHost object).
This approach seems to solve the overlapping issue. The next thing i need to try is to let users click on the dummy title bar and drag the MDI window inside the canvas element.
Questions -
Is my understanding about WPF webbrowser control overlapping behavior right? If not, what am i missing?
Is the second approach a step in right direction for accomplishing what i want? If yes, how do i implement the drag behavior for HwndHost?
Is there any other alternate solution i can try?
Note:
Although many consider MDI not an elegant solution, I do not have a choice. (We tried alternate solutions like tabbed windows/dockable
windows, but were not well received)
I am quite new to interop programming, and do not understand the
concepts well. Please correct me if i am misunderstanding things.
Thanks!

Panel does not resize controls while creating control image

I need to create an image of a custom WPF control and save it to file. I do it by this way (http://denisvuyka.wordpress.com/2007/12/03/wpf-diagramming-saving-you-canvas-to-image-xps-document-or-raw-xaml/).
The control contains several panels (ie. StackPanel). When this control is rendered on the form it looks perfectly. But when I render it in memory and save to file all controls in panels are not aligned. They take area that they need only and they doesn't stretch.
When I used WPF 3.5 it worked. This issue appeared after I updated my project to WPF 4.0.
Could anybody explain me what changes in WPF 4.0 cause this behaviour and how I can resolve it?

Is there a way to make a winforms usercontrol in a WindowsFormsHost larger?

I have a few usercontrols from an old Windows CE project that I'd like to have in a WPF window, so I've copied the code/design over to the WPF project and dropped the usercontrol into a WindowFormsHost object. It appears to work fine, but the control looks rather small and I'd like to make it bigger. I tried a viewbox but this doesn't actually make it larger (which I kind of expected since it's based around the vector based WPF system). Does anyone know if any way to make a Winforms usercontrol larger in this setting?
Unless the Winforms control(s) use docking or anchoring so they resize with the container there is no easy way to do this.
Perhaps you could change the code of the Winforms controls so they do dock and/or anchor. But even when you do this, fonts will not size along.

Dynamically adding ElementHost'd WPF UserControl to WinForms results in Black

I have a WPF user control inside an ElementHost that is inside a WinForms control to wrap it. I'm dynamically adding it to a tab control tab.
But when I do this, my WPF control is black.
How do I fix that?
There are many alternative solutions on the web to this one. However, what fixed it for us was to avoid "Fill" docking the element host within it's parent control. If you are using docking, then give it a try!
Unfortunately this can be one of those evil problems solved by experimentation and it'll turn out to be a one line fix!
It was my own mistake. I forgot to add the WinForms tab control panel (a 3rd party one) to the right class.

Need to tab out of ActiveX control in browser

When tabbing through controls in an ActiveX control hosted in IE, once I get to the last control the tab key no longer does anything. I would like it to move the focus outside the ActiveX control to the next html control.
This works fine when the ActiveX control is hosted in a WinForms app, does anybody know how to make this work in the browser?
It may also be relevant that the ActiveX control is a simple wrapper around a WPF control.
I found a hacky solution.
The problem is tabbing out of the WPF control, so I've placed a hidden textbox after the ElementHost within the ActiveX control. Tabbing out of the WPF control moves focus to the hidden control correctly, which upon receiving focus uses SendKeys("{TAB}".
Just typing SendKeys makes me feel a little dirty though, so if anyone has a better solution...

Resources