Click here to Skip to main content
11,571,471 members (75,646 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Win7 screen
Anyone else have this problem and/or a work-around?

I would like my application to be nicely sized and centered so I have code like this:
            int border = 50;
            System.Drawing.Rectangle rr = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            if (Width > rr.Width - border)
                Width = rr.Width - border;
            if (Height > rr.Height - border)
                Height = rr.Height - border;
            Left =  (rr.Width - ActualWidth) / 2;
            Top = (rr.Height - ActualHeight) / 2;;
and this works properly when the Windows 7 font size is set to 100%. The screen resolution is 1920x1080.

When I go (in Windows 7) to "Make text and other items larger or smaller" and set the size to medium (125%), things break. 'rr' still shows 1920x1080 and the application hangs off the edge of the screen. If I maximize the application, it reports an ActualWidth, ActualHieght of only 1550x840 (which is, oddly enough, about 1920x1080 / 125%).

It seems that Windows makes everything bigger by making the pixels bigger but doesn't understand that that means there will be fewer pixels on the screen. How do I get Windows to tell me how big the scren really is, not how big it might have been? Or where can I find that 125% size setting so I can do the division myself?
Posted 15-Apr-12 17:34pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks for your answer, it led me to the actual answer...

Since I'm in WPF, there are properties in SystemParameters which seem to work.

   Rect rr = new Rect() { Width = SystemParameters.PrimaryScreenWidth, Height = SystemParameters.PrimaryScreenHeight };
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There are some properties to look at: AutoSize, AutoSizeMode, AutoScaleMode. But they do interfere with each other...
  Permalink  

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

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | Last Updated 16 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100