多监视器系统上的ContextMenuForm位置 [英] ContextMenuForm Postion on Multi-Monitor System

查看:89
本文介绍了多监视器系统上的ContextMenuForm位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我对C#的首次尝试-尝试修复"我正在使用的开源应用程序,因此请保持警惕!该应用程序窗口停靠在我的中央监视器的右侧.右键单击时,上下文菜单将出现在右侧监视器上,并且我希望将其保留在中央监视器上.

我有一个ContextMenuForm_opening事件.那是控制上下文菜单位置的最佳位置吗? System中的多监视器/桌面大小/监视器检测内容在哪里?

干杯

This is my first foray into C# - trying to ''fix'' an open source app I''m using, so please be gentle!. The app window is docked to the right of my center monitor. When I right click, the context menu appears on my right-hand monitor and I want to keep it on the centre monitor.

I have a ContextMenuForm_opening event. Is that the best place to control the context menu position? And where in System does the multi-monitor / desktop size / monitor detection stuff live?

Cheers

推荐答案

对于System.Windows.Forms,使用类 System.Windows.Forms.Screen完成多显示器编程;请参阅:
http://msdn.microsoft.com/en-us/library/system. windows.forms.screen.aspx [ ^ ].

您也可以使用虚拟屏幕,但您的系统已配置为虚拟屏幕.请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.virtualscreen.aspx [ ^ ].

使用WPF,我不知道类似的功能.您可以通过P/Invoke使用Windows API.从这里开始:
http://msdn.microsoft.com/en-us/library/dd162610%28v = vs.85%29.aspx [ ^ ].

在Windows 7中,您可以使用WindowsAPICodePack通过跳转列表管理WPF屏幕,请参阅以下文章:
http://aimeegurl .com/2009/11/06/managing-wpf-screens-with-windows-7-jumplists-and-the-visual-state-manager/ [ http://links.visibli.com/e411f38896eb5888/?web=1d37cf&dst=http%3A//windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview. aspx [
With System.Windows.Forms, multi-monitor programming is done using the class System.Windows.Forms.Screen; please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx[^].

You can also work with virtual screen, it your system is configured so. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.virtualscreen.aspx[^].

With WPF, I don''t know the analogous facilities. You can use Windows API through P/Invoke. Start here:
http://msdn.microsoft.com/en-us/library/dd162610%28v=vs.85%29.aspx[^].

With Windows 7, you can manage WPF screens with Jumplists using WindowsAPICodePack, please see this articles:
http://aimeegurl.com/2009/11/06/managing-wpf-screens-with-windows-7-jumplists-and-the-visual-state-manager/[^],
http://links.visibli.com/e411f38896eb5888/?web=1d37cf&dst=http%3A//windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx[^].

—SA


这篇关于多监视器系统上的ContextMenuForm位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆