Ok, I am really hoping there is someone who has some experience with old Cobol forms(exe's) and loading them into an MDI Parent as an MDI child. At the moment, I am calling the exe file as a process, but from what I see at the moment, there is no way to load the process onto the MDI Parent. Would anybody know how to do this?

I have also tried with the Assembly.LoadFile and .LoadFrom methods but I keep getting a manifest error. Any insight would be greatly appreciated.

I should probably also mention that I have tried using the SetParent Windows API.

What code are you using to call the SetParent routine? What is it doing wrong or not doing right? If done correctly and the COBOL form will run correctly it should work.

Edited 2 Years Ago by tinstaafl

[DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        Process process = Process.Start(filetoexecute, args);
                    process.StartInfo = si;
                    process.EnableRaisingEvents = true;
                    process.Exited += ProcessExited;
                    process.StartInfo.CreateNoWindow = true;

                        SetParent(process.Handle, mainform.handle);

I have tried process.MainWindowHandle but it is always 0, even if I refresh it.

See if this works:

Process process = new Process();
process.StartInfo = si;
process.StartInfo.FileName = filetoexecute;
process.StartInfo.Arguments = args;
process.EnableRaisingEvents = true;
process.Exited += ProcessExited;
SetParent(process.MainWindowHandle, this.handle);

Sorry it took so long to respond. I just tried it and it still didn't work. What's kind of wierd is that when the application opened, it pulled in a screen behind my application (my visual studio screen with code) and placed it on the form. I think we'll go ahead and leave as is for now without setting the MDI parent.

This article has been dead for over six months. Start a new discussion instead.