Click here to Skip to main content
15,886,718 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Dear all,
I am having a windows application in which I disabled the screen resizing (including maximizing).Now I am looking for a C# code that should dock my form to left side of my screen (please consider I am using double monitors, so form should be docked to respective monitor only)when user double clicks the title bar. Is there is any possibility to do this??. Can anyone help me on this ??.
Thanks in advance..
Posted
Comments
Sergey Alexandrovich Kryukov 15-Nov-14 1:29am    
What's wrong with just reading original MSDN documentation?
—SA
Manu Prasad 15-Nov-14 2:24am    
Sorry I am a beginner I don't know even the basics about system.windows.forms.screen...
Sergey Alexandrovich Kryukov 15-Nov-14 2:45am    
It's perfectly fine. Not everything worth knowing. Learn the fundamentals, read about everything else.
Will you use my answer? Accept it formally?
—SA
Manu Prasad 15-Nov-14 2:57am    
Sure..
Sergey Alexandrovich Kryukov 15-Nov-14 2:58am    
Good luck, call again.
—SA

1 solution

First of all, you need to find the screen metrics. This is how:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.allscreens(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.primaryscreen%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.workingarea%28v=vs.110%29.aspx[^].

Note that you can have several screens or one big virtual screen. In case of several monitors showing separate screens, you can choose one.

Now, you can calculate the location and desired size of the form. And move/resize it using its properties Size and Location:
http://msdn.microsoft.com/en-us/library/25w4thew(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/ms159414(v=vs.110).aspx[^].

Simple, isn't it?

—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