Click here to Skip to main content
15,668,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I want to perform some operation when our application window is moved from primary screen to secondary screen.I tried the following code also
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromRectangle(new System.Drawing.Rectangle((int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height));
               if (!screen.Primary)
                   this.MaxHeight = screen.WorkingArea.Height + 2;

But it doesn't work when window in mouse focus during the movement of our application window from primary screen to secondary screen.

So please help me on this

VR Karthikeyan 13-Oct-15 1:30am    
Are you wants to track the Mouse Movement?
Member 11952134 13-Oct-15 4:37am    
Yes Karthikeyan.I want to change when maxheight of my application when enter to secondary window from primary window.I want to perform some event when screen schanged from primary to seconadry. Is there is any event available?
Philippe Mori 13-Oct-15 12:52pm    
If you don't do anything then Windows will limit the size of the application to the screen on which it is is mainly displayed thus to me, it seems to be useless to track this...

And by the way, why are you checking if the form is not on the primary screen? It is a really weird requirement.

It does not make much sense to do something that goes against the way the system usually works for most applications. If you don't know what you are doing, then it will probably be bugged in some cases or don't work as expected in some configurations...

If you need more control than what .NET offers, then you have to go to the API level. I don't think that it worth the effort. Try how other applications work in that case.

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