创建一个.NET应用程序,"码头"在屏幕上,并限制其他窗口'尺寸的一面,当最大化创建一个、码头、应用程序、尺寸

2023-09-03 06:22:42 作者:〆半度微笑°

我从更高的跌宕一个有趣的请求。他们希望有一个简单的应用程序,将显示在用户计算机上显示多个时区的时间。也就是说,在本身,是微不足道的;一个简单的窗口,一个计时器,将获得当前UTC时间,将其转换为任意数量的,他们希望看到更新一些标签的文本时区。

I got an interesting request from the higher ups. They want a simple app that will show on users' computers to display the time in multiple time zones. That, in itself, is trivial; a simple window with a timer that will get the current UTC time and convert it to any number of time zones they want to see to update some labels' text.

这里的难题,虽然,以满足各地的需求,窗口不能晦涩,也可以通过其他任何桌面上的模糊。用户将可以运行的必须是完全可见在任何时候其他应用程序,并在同一时间这个程序不能覆盖这些窗口之一。

Here's the rub, though; to meet requirements all around, the window can never obscure nor be obscured by anything else on the desktop. The user will be running other applications that must be fully visible at all times, and at the same time this app cannot be covered by one of those windows.

所以,我想在以下两种方式之一实现它的:

So, I was thinking of implementing it in one of two ways:

作为一个应用程序,是总在最前面,但背景是完全透明的,时间显示为50%透明或一些这样的。移动鼠标在窗口会突出,拆除其透明性和/或增加不透明的高对比度背景的时间显示。 AFAIK这个解决方案不能使用Windows Aero的,因为初级用户的操作系统是Windows XP中。

As an app that is always on top, but the background would be completely transparent and the time displays would be 50% transparent or some such. Moving the mouse over the window would "highlight" the time displays by removing their transparency and/or adding opaque high-contrast backgrounds. AFAIK this solution cannot use Windows Aero, because the OS of the primary users would be Windows XP.

由于使用低级别的Windows消息以某种方式模仿Windows任务栏在其总在最前面模式的行为的应用程序;它将停靠在屏幕的顶部,将始终在正常 - 状态窗口的上面显示,另外将管理的其它窗口的最大化的行为,这样最大化时这些窗口不重叠的。

As an app that uses low-level Windows messages to somehow mimic the behavior of the Windows taskbar in its "always on top" mode; it will dock to the top of the screen, will always show on top of "normal"-state windows, and additionally will govern the "maximize" behavior of other windows so that those windows won't overlap it when maximized.

我真的不知道从哪里开始实施其中任意一个,但我会大胆地猜测,鉴于WinXP的限制,第二个选择是比较容易,如果有可能的话。因此,要实现什么样的行为,我会寻找以告知Windows从来没有最大限度地发挥了我的窗体顶端?

I really have no idea where to start to implement either of these, but I would hazard a guess that given the WinXP limitation, the second option is easier if possible at all. So, what behaviors would I be looking to implement to tell Windows to never maximize over the top of my form?

推荐答案

作为墓志铭,因为汉斯帕桑特似乎沉默后回答,我发现,我需要的是使应用程序的应用程序桌面工具栏,或者Appbar 。在codePLEX链接汉斯了, HTTP://$c$cproject.com/ KB / DOTNET / AppBar.aspx ,以及关于该主题的MSDN文章的http://msdn.microsoft.com/en-us/library/windows/desktop/cc144177%28v=vs.85%29.aspx,给了很多的信息。我能pretty的多副本/从$的code中的区域粘贴C $ CPLEX定义AppBar行为纳入其他正常NET的形式,创建一个简单的概念验证的:

As an epitaph, since Hans Passant seems reticent to post answers, I found that what I needed was to make the app an "Application Desktop Toolbar", or Appbar. The CodePlex link Hans gave, http://codeproject.com/KB/dotnet/AppBar.aspx, as well as the MSDN article on the topic, http://msdn.microsoft.com/en-us/library/windows/desktop/cc144177%28v=vs.85%29.aspx, give a lot of information. I was able to pretty much copy/paste the region of code from CodePlex defining the AppBar behavior into an otherwise normal .NET form, to create a simple proof-of-concept:

在一个改变我从codePLEX code作出了断绝RegisterBar()从code眼泪下来注册表单作为AppBar的一半,所以打电话给RegisterBar ()总是这样交替地注册和未注册也正是替代。

The one change I made from the CodePlex code was to sever the half of RegisterBar() that registers the form as an AppBar from the code that tears it down, so a call to RegisterBar() always does exactly that instead of alternately registering and un-registering it.