I have an old windows mobile application that the boss wants running on Windows 7. Since it’s all .NET, the application runs, sort of, on Windows (it was made for Windows CE I believe), but it runs in a tiny window. I’d like to blow that up, and the first thing that came to mind was somehow dumping the actual program inside of a WPF Viewbox. It would be fairly simple and not infringe on the size of any of the other applications.
Searching around all I see is info on WindowFormsHost for putting WinForms usercontrols in WPF, but nothing about a full executable. Does anyone know if there’s a way to do this?
Viewbox only works for pure WPF controls. You can’t use it to enlarge a WinForms control, because WinForms controls don’t know anything about WPF’s scale transforms.
You could try to hack something together using the WinForms Control.DrawToBitmap method: draw the WinForms control to a bitmap, then enlarge the bitmap and draw it to the screen. (No WPF required; you could do this in pure WinForms.) But DrawToBitmap has serious limitations. And if you wanted your app to respond to the mouse or keyboard, you’d have a lot of work to do, forwarding mouse and keyboard events to the original control, keeping track of focus yourself, etc. Maybe theoretically possible, but almost certainly not practical.
It is possible to load a .NET EXE into another .NET EXE. EXEs are assemblies just like DLLs, and you can load them with Assembly.Load, or even Add Reference in Solution Explorer. But you don’t need to do anything that exotic; you could just as easily compile all the source code into your host EXE to begin with.
Your best bet is probably just to open each form in the form designer and make all the controls bigger. It could be a lot of work in a large application, but there’s nothing saying you have to do it all at once — and it’d probably be less work than any of the alternatives.