Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 2-Apr-12 19:59pm    
To start with, there is no such event as "ContextMenuForm_opening", this is one of the possible handlers. Yes, such handler is a right place to change the menu position, before it was actually shown. The position itself may vary.
--SA
Sergey Alexandrovich Kryukov 2-Apr-12 20:01pm    
The second question is simple, but you need to tag application type or UI library you use. WPF? Forms? Anything else?
--SA

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900