简体   繁体   English

在WinForm中的TabControl内启动我的应用程序时,MenuStrip和StatusStrip不起作用

[英]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. 我需要在WinForm中的TabControl的TabPage中启动我的应用程序。 It works fine but when I click on MenuStrip items, it doesn't show sub menu. 它工作正常,但是当我单击MenuStrip项时,它不显示子菜单。 However Click event works.Plus, I used a label in StatusStrip as button and Click event doesn't fire. 但是Click事件有效。此外,我在StatusStrip中使用标签作为按钮,但Click事件不会触发。

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. 甚至我将AllowMerge设置为False。 How can I make it work ? 我该如何运作?

thanks. 谢谢。

I couldn't find any solution to make .Net MenuStrip work in this case. 在这种情况下,我找不到任何使.Net MenuStrip工作的解决方案。

For those who have the same problem, I've tested DevExpress XtraBars Bar, it works great ! 对于那些有相同问题的人,我已经测试过DevExpress XtraBars Bar,它很棒! So I switched to DevExpress menu bar. 所以我切换到DevExpress菜单栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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