C#的Windows不开放顶部 [英] C# Windows not opening on top

查看:94
本文介绍了C#的Windows不开放顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了有很多的对话框和表格等
我与 Form.ShowDialog打开这些比较大的应用程序()

I've written a relatively large application with lots of dialog boxes and forms, etc. I'm opening them with Form.ShowDialog().

很多时候,表格后面打开现有窗口,例如:昨天,我的机器上打开几个其他程序对其进行测试:许多Windows资源管理器窗口,几个Excel的窗户,等我的很多形式,打开/保存文件对话框等被认为打开,但没有。我闲得无聊,直到我按下Alt + Tab,并意识到他们,其实背后的另一个窗口。

A lot of the time, the forms open behind existing windows, e.g. yesterday I was testing it on a machine with several other programs open: many Windows Explorer windows, a few Excel windows, etc. A lot of my forms, open/save file dialogs, etc were supposed to open but didn't. I was twiddling my thumbs until I pressed alt+tab and realised that they were, in fact, behind another window.

这是怎么回事,我怎么能阻止它在未来?谢谢你。

Why is this happening, and how can I stop it in future? Thanks.

推荐答案

使用的 的ShowDialog 覆盖它接受一个所有者窗口作为一个参数。

Use the ShowDialog override which takes an owner window as a parameter.

通过传递你的主窗口,对话框的所有者,你保证该对话框总是弹出在它的面前,并保持在它的前面。

By passing in your main window as the dialog's owner, you guarantee that the dialog always pops in front of it, and stays in front of it.

和它将不在乎,如果他们使用其他应用程序的用户。

And it won't annoy the user if they were using some other application.

这篇关于C#的Windows不开放顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆