窗体A跳转到窗体B的时候,需要先回到桌面,然后在跳出窗体B,请问这个问题怎样解决?

解决方案 »

  1.   

    // in formA
    WindowState = FormWindowState.Minimized;
    Application.DoEvents();
    System.Threading.Thread.Sleep(1000);
    this.Hide();
    new FormB.Show();
      

  2.   

    如caozhy,先最小化本窗体,再显示B
      

  3.   


            private void button1_Click(object sender, EventArgs e)
            {
                System.Timers.Timer timer = new System.Timers.Timer(2000);//显示桌面2秒后弹出Form2
                timer.Elapsed += timer_Elapsed;
                Type oleType = Type.GetTypeFromProgID("Shell.Application");
                object oleObject = System.Activator.CreateInstance(oleType);
                oleType.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, oleObject, null);
                timer.Start();
            }        void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                System.Timers.Timer timer = sender as System.Timers.Timer;
                timer.Stop();
                this.Invoke(new Action(() => {
                    Form2 f = new Form2();
                    f.Show();
                    f.Activate();
                }));
            }
      

  4.   


    要死了
    显示桌面搞这么麻烦
    又是COM
    又是时钟
    又是() =>
      

  5.   

    cmd里有命令可以直接显示桌面,然后你再b.show
      

  6.   

    额……曹哥太夸奖了,我哪能算得上大牛呢……
    论坛冷清,csdn应该好好反思,不解决症结所在情况只会越来越糟。
      

  7.   

    不是啊亲们,我说的是 窗体A跳转到窗体B的时候,程序会先回到桌面,然后在跳出窗体B,就是这个闪烁了一下差不多0.5~1S,这样显得程序视觉效果太差了,请问怎样解决这个问题
      

  8.   

    用SetForegroundWindow把B调出来,然后hide A或者先B arctive(),然后hide A
      

  9.   

                绝对简单好用           
               this.Visible = false;
                Form2 f2 = new Form2();
                System.Threading.Thread.Sleep(1000);
                f2.Show();要想在弹出之前显示桌面可以调用API,加上代码
         [DllImport("user32.dll", EntryPoint = "SetParent")]
            public static extern int SetParent(int hWndChild, int hWndNewParent);        [DllImport("user32.dll", EntryPoint = "FindWindow")]
            public static extern int FindWindow(string lpClassName, string lpWindowName)