最上面的表格? [英] Form top most?

查看:125
本文介绍了最上面的表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能显示东西比其他所有应用程序。我想显示的东西在所有形式的我的程序和所有其他程序打开我的桌面(不是我的)上。

How can I display something over all other application. I want to to display something over all form of my program and all other programs open on my desktop (not mine).

*最上面的不工作我已经测试和我的浏览器可以在我的应用程序:•

下面是当我用最顶层为TRUE的图像。你可以看到我的浏览器是在它...

Here is an image of when I use TopMost to TRUE. You can see my browser is over it...

<一个href="http://www.freeimagehosting.net/uploads/5a98165605.png">http://www.freeimagehosting.net/uploads/5a98165605.png

推荐答案

您可以使用表格实例,并设置该属性的最顶层为True。

You can use the form instance and set the property TopMost to True.


如果你想在所有的Windows,还有另一种方式是的Win32 API 的电话。


If you want to be over all Windows, there are another way with Win32 Api calls.

下面是你可以做的:

在表单类中添加:

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

在窗体加载,你可以添加:

In the form load you can add :

SetForegroundWindow(this.Handle);

这应该可以解决问题。

最顶层应该做的工作,但:最顶端或/和Win32 API调用只会工作,不会在Visual Studio中(也适用于Vista和我测试了VS2008 ......我不能告诉其他)。尝试从/ bin目录中运行具有.exe程序,它会工作。

TopMost should do the job BUT: Top most OR/AND the Win32 Api call will only work not inside Visual Studio (well for Vista and with VS2008 I tested it... I can't tell for other). Try running the program with the .Exe from the /bin directory, it will works.

这篇关于最上面的表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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