Windows 7 风格的系统托盘弹出窗口

发布于 2024-09-03 17:49:05 字数 1283 浏览 2 评论 0原文

我想要这样的东西:

托盘弹出窗口
(来源:cybernetnews.com)

此窗口不可调整大小,并在与其相关的系统托盘图标上方对齐。

我有这个:

Tray popup

这是可调整大小的,它可以随心所欲地移动。如果您在 Win 7 中单击音量控制,它总是会直接在图标上方弹出。这是理想的。

我发现此参考我认为是试图解决同样的问题(无法判断,因为图像已死),

但我正在使用 WPF,并且我不确定如何从我的 Window 对象获取它们引用的这些 Form 对象。这是我当前窗口的 XAML 声明:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="WirelessControl.Window1"
x:Name="Window"
Title="Window1"
Width="260" Height="370" mc:Ignorable="d" WindowStyle="None"></Window>

我觉得基于这在 Windows 中的常见程度,必须有一种相当简单的方法来做到这一点。

ResizeMode="NoResize" 导致我的窗口边框消失,所以这没有帮助。

谢谢大家,我希望我说得足够全面。

I want something like this:

Tray popup
(source: cybernetnews.com)

This window is not resizable, and aligns itself above the system tray icon which it is related to.

I have this:

Tray popup

Which is resizeable, and it goes wherever it feels like. If you click the volume control in Win 7, it always pops up directly above the icon. This is ideal.

I've found this reference which I think is trying to solve the same problem (can't tell though as the images are dead),

but I'm using WPF and I'm not sure how to get these Form objects they refer to from my Window object. This is the XAML declaration of my window at the moment:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="WirelessControl.Window1"
x:Name="Window"
Title="Window1"
Width="260" Height="370" mc:Ignorable="d" WindowStyle="None"></Window>

I feel like based on how common this is in Windows that there must be a fairly easy way to do this.

ResizeMode="NoResize" causes my window border to disappear, so that's no help.

Thanks guys, I hope I was comprehensive enough.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

守不住的情 2024-09-10 17:49:05

您可以使用 Shell_NotifyIconGetRect 检索通知图标。然后,您可以重新定位窗口以匹配该位置。这就是音量控制 UI 的作用。不幸的是它只适用于Win7。

如果您需要在较旧的操作系统上工作,您可以在出现 NIN_BALLOONSHOW 消息时获取鼠标光标位置 - 这就是音量控制 UI 的用途。

You can use Shell_NotifyIconGetRect to retrieve the location of the notification icon. You can then reposition your window to match that location. That's what the volume control UI does. Unfortunately it only works on Win7.

If you need to work on older OS's, you can get the mouse cursor position at the time of the NIN_BALLOONSHOW message - that's what the volume control UI used to do.

猛虎独行 2024-09-10 17:49:05

我在这里写了一系列关于执行此操作的帖子(并制作了一个示例项目): http://blog.quppa.net/2011/01/03/windows-7-style-notification-area-applications-in-wpf- recap-sample/

涵盖的主题包括在不删除玻璃边框的情况下删除窗口大小调整、查找通知图标的位置(在 Windows 7 中使用 Shell_NotifyIconGetRect 以及在早期版本中使用更 hacky 的方法)、查找任务栏停靠对齐当存在多个屏幕(监视器)时找到正确的工作区域。虽然我并没有真正写过它,但示例代码包括未启用 DWM(读:Aero)的系统的后备(即,以 Windows 7 通知区域应用程序的样式绘制自定义 1 像素边框)。

I've written a series of posts about doing this (and made a sample project) here: http://blog.quppa.net/2011/01/03/windows-7-style-notification-area-applications-in-wpf-recap-sample/

Topics covered include removing window resize without removing the glass border, finding the position of the notify icon (both with Windows 7 using Shell_NotifyIconGetRect and with earlier versions using a more hacky method), finding the taskbar docking alignment and finding the correct working area when there are multiple screens (monitors) present. Though I didn't really write about it, the sample code includes fallbacks for systems where the DWM (read: Aero) is not enabled (that is, drawing a custom 1 pixel border in the style of the Windows 7 notification area applications).

一袭白衣梦中忆 2024-09-10 17:49:05

我在这篇帖子

唯一的问题是调整大小光标仍然可见。我认为你可以通过操纵窗口的消息循环来隐藏它们。

I have answered a question just like yours in this post

the only problem is that the resize cursers are still visible. I think you can hide them by manuplating the window's message loop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文