使图形元素“像码头一样”
具体来说,我尝试将我的元素重叠在所有内容之上,包括桌面,类似于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.