Running .exe gui in a windows form container

G

Gerry

I need to display two VB6 applications side by side within a single
'windows manager'

My thought is that I could use a split screen form, using the 2.0
framework and visual studio 2005, that display the UI of each of the
VB6 apps within some control or container on the windows form.

The obvious solution is to rebuild the VB6 apps as com objects and
place the com objects on the form. Is there a solution that doesn't
require me to rebuild the VB6 apps?
 
G

Greg Young [MVP]

Something like this ??

namespace WindowsApplication2

{

public partial class Form1 : Form {

public Form1()

{

InitializeComponent();

}

private void LoadProcessInControl(string _Process, Control _Control)

{

System.Diagnostics.Process p = System.Diagnostics.Process.Start(_Process);

p.WaitForInputIdle();

Native.SetParent(p.MainWindowHandle, _Control.Handle);

}

private void Form1_Load(object sender, EventArgs e)

{

LoadProcessInControl("notepad.exe", this.splitContainer1.Panel1);

LoadProcessInControl("notepad.exe", this.splitContainer1.Panel2);

}

}

public class Native {

[DllImport("user32.dll", SetLastError = true)]

public static extern uint SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

}

}
 
G

Greg Young [MVP]

You are correct ... but the other alternative is the CreateDesktop route
which from what I understand which get extremely nasty and this works on
everything now.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top