C# - 为什么不是全屏WinForm的应用始终覆盖任务栏?全屏、任务栏、不是、WinForm

2023-09-05 23:01:57 作者:扶南

我使用Windows Vista和C#.net 3.5,但我有我的朋友上运行XP的程序,并且有同样的问题。

I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem.

所以,我有我在的SystemTray中的图标在后台正在运行的C#程序。我有一个低级别的键盘钩子,所以当我preSS的两个键(CTR +窗口在这种情况下),它会拉动应用的主要形式。表单设置为在组合键preSS全屏甚至处理程序:

So I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in this case) it'll pull of the application's main form. The form is set to be full screen in the combo key press even handler:

this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;

因此​​,它基本上是工作。当我打的点击率+视窗它带来了形式,无论什么项目我已焦点。但有时,任务栏仍然会出现过的形式,这是我不想要的。我希望它永远是全屏幕,当我打的关键组合。

So it basically works. When I hit CTR+Windows it brings up the form, no matter what program I have given focus to. But sometimes, the taskbar will still show up over the form, which I don't want. I want it to always be full screen when I hit that key combo.

我想,这事做什么应用程序最初集中。但是,即使当我点击我的主要形式,在任务栏有时会在那里停留。所以我想如果焦点确实是问题。这似乎只是有时在任务栏上的固执和不希望坐在后面我的程序。

I figure it has something to do with what application has focus originally. But even when I click on my main form, the taskbar sometimes stays there. So I wonder if focus really is the problem. It just seems like sometimes the taskbar is being stubborn and doesn't want to sit behind my program.

任何人有任何想法如何解决这个问题?

Anyone have any ideas how I can fix this?

编辑:更多详情 - 我试图达到同样的效果,当你把它变成全屏模式,或当你把PowerPoint中插入presentation模式。

More details- I'm trying to achieve the same effect that a web browser has when you put it into fullscreen mode, or when you put powerpoint into presentation mode.

在Windows窗体你这样做,通过把边框样式为none和最大化的窗口。但有时窗口将不包括任务栏上的某些原因。一半的时间会。

In a windows form you do that by putting the border style to none and maximizing the window. But sometimes the window won't cover the taskbar for some reason. Half the time it will.

如果我有主窗口最上面,其他人将落在后面,当我点击它,我不想当任务栏被隐藏。

If I have the main window topmost, the others will fall behind it when I click on it, which I don't want if the taskbar is hidden.

推荐答案

试试这个(其中是表单):

Try this (where this is your form):

this.Bounds = Screen.PrimaryScreen.Bounds;
this.TopMost = true;

这将设置形式到全屏,它会覆盖任务栏。

That'll set the form to fullscreen, and it'll cover the taskbar.