如何解决C#窗体跳转问题 窗体A跳转到窗体B的时候,需要先回到桌面,然后在跳出窗体B,请问这个问题怎样解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // in formAWindowState = FormWindowState.Minimized;Application.DoEvents();System.Threading.Thread.Sleep(1000);this.Hide();new FormB.Show(); 如caozhy,先最小化本窗体,再显示B 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(); })); } 要死了显示桌面搞这么麻烦又是COM又是时钟又是() => cmd里有命令可以直接显示桌面,然后你再b.show 额……曹哥太夸奖了,我哪能算得上大牛呢……论坛冷清,csdn应该好好反思,不解决症结所在情况只会越来越糟。 不是啊亲们,我说的是 窗体A跳转到窗体B的时候,程序会先回到桌面,然后在跳出窗体B,就是这个闪烁了一下差不多0.5~1S,这样显得程序视觉效果太差了,请问怎样解决这个问题 用SetForegroundWindow把B调出来,然后hide A或者先B arctive(),然后hide A 绝对简单好用 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) Office Communicator Server编程问题 服务器的监听 卡死 如何抽象数据对象 请教如何判断随机数区间 怎么实现:连接远程数据库的时候,用户不能做任何操作 给readonly 变量赋值到底错在哪里? 单点登录怎么做 C# winform设计的书 cs页面修改控件属性 求教 传值问题 发送网页源码时会生成一句代码,就出问题了。
WindowState = FormWindowState.Minimized;
Application.DoEvents();
System.Threading.Thread.Sleep(1000);
this.Hide();
new FormB.Show();
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();
}));
}
要死了
显示桌面搞这么麻烦
又是COM
又是时钟
又是() =>
论坛冷清,csdn应该好好反思,不解决症结所在情况只会越来越糟。
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)