本文介绍了我怎样才能把我的应用程序窗口的前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何把我的应用程序窗口前?例如焕我的应用程序需要注意。
How to bring my application window to front? For example whan my app needs attention.
这是我个人的计划。我需要的功能。
This is for my personal program. I need that functionality.
这是我得到了什么。但它的不可以工作100%倍。
This is what I got. But it's NOT working 100% times.
public void BringToFrontToEnterCaptha()
{
if (InvokeRequired)
{
Invoke(new Action(BringToFrontToEnterCaptha));
}
else
{
this.TopMost = true;
this.Focus();
this.BringToFront();
this.textBox1.Focus();
this.textBox1.Text = string.Empty;
System.Media.SystemSounds.Beep.Play();
}
}
public void BringToBackAfterEnterCaptha()
{
if (InvokeRequired)
{
Invoke(new Action(BringToBackAfterEnterCaptha));
}
else
{
this.TopMost = false;
}
}
和我的背景工人给他们打电话。
And I call them from background worker.
BringToFrontToEnterCaptha();
while (!ready)
{
Thread.Sleep(100);
}
BringToBackAfterEnterCaptha();
Thread.Sleep(300);
和之后pressing接受按钮布尔准备设置为true。
And after pressing "Accept" button bool ready is set to true.
我的伟大工程,但并非总是如此。
I works great but not always.
推荐答案
使用<$c$c>Control.BringToFront:
myForm.BringToFront();
这篇关于我怎样才能把我的应用程序窗口的前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!