I have a .NET 4.5 C# winforms app that, when a barcode scan is detected, is supposed to come to the foreground (in front of all other apps/windows). I'm using this code to accomplish it:
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
this.Activate();
This works perfectly on Windows 7 but doesn't work on Windows 8. If my app is only minimized (and was the most recent app to have focus), it does work, with this line:
this.WindowState = FormWindowState.Normal;
But if any other window/app is IN FRONT OF my app when the barcode scan occurs, this.Activate()
clearly doesn't work on Windows 8.
What is the solution?
您需要设置表单的TopMost属性。
this.TopMost = true;
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.