获取 Windows 上下文菜单选择的位置?
我有一个 Windows 上下文菜单项,通过这些注册表项调用 Windows 窗体...
HKLM\Software\Classes\*\shell\myappname
HKLM\Software\Classes\*\shell\myappname\command
但是当我的 Windows 窗体启动时,我希望它位于调用上下文菜单的位置附近。有什么办法可以做到这一点吗?我想我需要获取Windows事件的坐标并设置窗口位置?
I have a Windows context menu item invoking a Windows Form via these registry keys...
HKLM\Software\Classes\*\shell\myappname
HKLM\Software\Classes\*\shell\myappname\command
But when my Windows Form is started, I want it to be located near where the context menu was invoked. Is there any way to do that? I think I need to get the coordinates of the Windows event and set the window location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的选择是使用 MousePosition 属性获取当前鼠标指针位置。这至少会减少用户移动鼠标与 Windows 窗体交互所需的距离。
Your best bet is to use the MousePosition property to get the current mouse pointer position. That will, at least, reduce the distance the user needs to move the mouse to interact with your Windows Form.