将表单放置在单击的通知图标上方
有没有办法将窗体放置在 Windows 7 和 Windows Vista 中单击的“通知”图标上方?
Is there a way to position a form just above the clicked Notify Icon in windows 7 and windows Vista?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个更简单的方法。
当 OnClick 事件触发时,您可以获取鼠标的 X,Y 位置。
您还可以通过从这些对象
Screen.PrimaryScreen.Bounds
、Screen.PrimaryScreen.WorkingArea
进行一些检查来获取任务栏位置。Here is an easier way.
You can get X,Y position of the mouse when the OnClick event is fired.
You can also get the taskbar position with somes checks from these objects
Screen.PrimaryScreen.Bounds
,Screen.PrimaryScreen.WorkingArea
.关于您的评论:“我怎么知道任务栏是如何定位的?”
查看以下文章,其中包含一个类,该类公开了用于检索 托盘的矩形结构:[c#] NotifyIcon - 检测 MouseOut
使用此类,您可以检索 托盘的矩形结构,如下所示:
它将为您提供托盘的顶部、左侧、右侧和底部坐标及其宽度和高度。
我已将以下课程包括在内:
希望这会有所帮助。
Regarding your comment: "how could i know how is the taskbar positioned?"
Check out the following article which contains a class which exposes a method for retrieving a Rectangle Structure for the tray: [c#] NotifyIcon - Detect MouseOut
Using this class you can retrieve the Rectangle Structure for the tray like so:
Which will provide you with the Top, Left, Right and Bottom coordinates for the tray along with its width and height.
I have included the class below:
Hope this helps.