c# user32.dll setparent prevents toolstrip click event from working

I am using the below code to launch an application and show it inside a "host" application.

Both are written in C#.Net

The problem is that once calling the User32.dll SetParent method the toolstrip buttons in the child application do not do anything. How can I get around this?
private void ShowMdiForm(string pExePath, ApplicationStruct pAppStruct)
        {
            //int processid = 0;
            XtraForm frm = CreateMdiForm(pAppStruct);

            using (Process p = new System.Diagnostics.Process())
            {
                p.StartInfo.FileName = pExePath;
                p.StartInfo.Arguments = "CamPortal";
                p.Start();
                p.WaitForInputIdle();

                IntPtr appWin = IntPtr.Zero;
                int tryCount = 0;

                while (appWin == IntPtr.Zero && tryCount < 50)
                {
                    // Get the main handle
                    System.Threading.Thread.Sleep(500); //Ensures that the handle can be grabbed

                    appWin = p.MainWindowHandle;
                    if (appWin == IntPtr.Zero)
                    {
                        //try again from a separate process
                        using (Process p2 = Process.GetProcessById(p.Id))
                        {
                            appWin = p2.MainWindowHandle;
                        }
                    }

                    //processid = p.Id;
                    tryCount++;
                }

                if (appWin != IntPtr.Zero)
               { 
                    pAppStruct.ApplicationHandle = appWin;
                    Application.DoEvents();
                    frm.Tag = pAppStruct;
                    frm.MdiParent = this;
                    frm.Show();
                    ResizeApp(frm);
                    frm.Icon = pAppStruct.ApplicationIcon;
                    IntPtr x = Usr32.SetParent(appWin, frm.Handle);
                }
                
            }


        }

Open in new window

CAMSYSTEMSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
When your host and the child are both .net applications then what is the need to use SetParent of User32?

You could add reference to that assemly and instantiate the required form and call showdialog method.

Do i make sense?
0
CAMSYSTEMSAuthor Commented:
Yeah you make sense however there are dll issues in this circumstance.

Basically we have a container application that hosts all of our other applications.... 10+

They all shared dll's and each dll could be different versions of the same dll's hence they need to be opened in their own process.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.