使图形元素“像码头一样”

发布于 2024-09-12 17:12:32 字数 296 浏览 4 评论 0原文

具体来说,我尝试将我的元素重叠在所有内容之上,包括桌面,类似于 Windows 中的任务栏。我有一个看起来有点像选项卡的 Windows 窗体控件。它的宽度约为 50 像素,长度约为 150 像素。我想做的是让该控件出现在所有窗口的前面,包括桌面本身。我说“类似停靠”是因为我相信停靠会推动窗口(因此,如果我的选项卡停靠了,它将推动任何全屏应用程序窗口超过 50 像素),这不是我想要做的。我希望我的选项卡覆盖在所有内容之上。我能想到的最接近的例子是Winamp。 Winamp 可以停靠在屏幕顶部,并且始终位于任何应用程序的顶部。

在 C# 中如何做到这一点?

Specifically, what I am try to is overlap my element on top of everything, including the desktop, similar to the taskbar in Windows. I have a Windows Form Control that looks kind of like a tab. its like 50px wide by like 150px in length. What I would like to do is have that control appear in front of all windows, including the desktop itself. I say "dock-like" because I belive docking pushes windows over (so if my tab was docked, it would push any full screen application window over 50px), which is not what I'm trying to do. I want my tab to overlay on top of everything. The closest example I can think of is Winamp. Winamp can dock to the top of the screen and it is always on top of any application.

how can do this in C#?

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

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

发布评论

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

评论(1

旧街凉风 2024-09-19 17:12:32

System.Windows.Forms.Form 有一个属性 TopMost,它将使窗体保持在其他窗口的顶部。

Winamp 的“捕捉”行为可以通过使用窗体的 Move 事件来实现 - 当窗体移动到足够靠近屏幕边缘时,以编程方式设置位置,使其位于屏幕上边缘。

System.Windows.Forms.Form has a property, TopMost, which will cause the form to stay on top of other windows.

The "snapping" behavior of Winamp can be implemented by using the Move event of the form--when the form is moved close enough to the edge of the screen, programatically set the position so that it's on the edge.

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