简体   繁体   中英

MenuStrip and StatusStrip doesn't work when Launch my app inside a TabControl in a WinForm

I need to launch my application inside a TabPage of a TabControl in a WinForm. It works fine but when I click on MenuStrip items, it doesn't show sub menu. However Click event works.Plus, I used a label in StatusStrip as button and Click event doesn't fire.

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = MYAPP;
info.Arguments = "/noresize";
info.UseShellExecute = true;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Minimized;
info.RedirectStandardInput = false;
info.RedirectStandardOutput = false;
info.RedirectStandardError = false;

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

p.WaitForInputIdle();
Thread.Sleep(3000);

Process[] p1;



var tp = new TabPage();

tp.Text = Path.GetFileName(file).Replace("Parser-", "").Replace(".exe", "");
tabControl1.TabPages.Add(tp);


if (p.MainWindowHandle == null)
{
    List<String> arrString = new List<String>();
    foreach (Process p2 in Process.GetProcesses())
    {
        // Console.WriteLine(p1.MainWindowHandle);
        arrString.Add(Convert.ToString(p2.ProcessName));
    }
    p1 = Process.GetProcessesByName(Path.GetFileName(file));
    //p.WaitForInputIdle();
    Thread.Sleep(5000);
    SetParent(p1[0].MainWindowHandle, tp.Handle);

    _intPtrs.Add(p1[0].MainWindowHandle);
}
else
{
    SetParent(p.MainWindowHandle, tp.Handle);
    _intPtrs.Add(p.MainWindowHandle);
}

even I set AllowMerge to False. How can I make it work ?

thanks.

I couldn't find any solution to make .Net MenuStrip work in this case.

For those who have the same problem, I've tested DevExpress XtraBars Bar, it works great ! So I switched to DevExpress menu bar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM