What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea
for the monitor that the window is currently on.
Clarification: The window in question is WPF
, not WinForm
.
What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea
for the monitor that the window is currently on.
Clarification: The window in question is WPF
, not WinForm
.
I needed to set the maximum size of my window application. This one could changed accordingly the application is is been showed in the primary screen or in the secondary. To overcome this problem e created a simple method that i show you next:
Beware of the scale factor of your windows (100% / 125% / 150% / 200%). You can get the real screen size by using the following code:
Also you may need:
to get the combined size of all monitors and not one in particular.
I wanted to have the screen resolution before opening the first of my windows, so here a quick solution to open an invisible window before actually measuring screen dimensions (you need to adapt the window parameters to your window in order to ensure that both are openend on the same screen - mainly the
WindowStartupLocation
is important)You can use this to get desktop workspace bounds of the primary screen:
System.Windows.SystemParameters.WorkArea
This is also useful for getting just the size of the primary screen:
System.Windows.SystemParameters.PrimaryScreenWidth
System.Windows.SystemParameters.PrimaryScreenHeight
in C# winforms I have got start point (for case when we have several monitor/diplay and one form is calling another one) with help of the following method: