[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Screen Size and Print Size

Mike

1/21/2005 10:49:00 PM

Hi,

Is there a way to determine the physical size of the client rectangle?

i.e. I have a panel i draw to, and I want to know the actual physical size
of the rectangle, regardless of the scren resolution.

My first attemp was just using e.Graphics.DpiX and e.Graphics.Pixel but
after reading I realized that e.Graphics.DpiX has to do with Fonts, not the
actual screen resolution.

I have tried setting the e.Graphics.PageUnit to GraphicsUnit.Inch, and then
looking at the VisibleClipBounds, but this doesn't work either.

Any help would be greatly appreciated.

Thannks.
mike


2 Answers

Bob Powell

1/22/2005 1:09:00 AM

0

Geaphics.Dpi(q) for a screen is the physical screen pixel pitch. You ca
certainly find the physical size from there on condition thatyou have a plug
and play monitor that reports its size correctly (some don't)


--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"mike" <mike@discussions.microsoft.com> wrote in message
news:0CDC6336-5F76-47EA-9251-0CB0EF407939@microsoft.com...
> Hi,
>
> Is there a way to determine the physical size of the client rectangle?
>
> i.e. I have a panel i draw to, and I want to know the actual physical size
> of the rectangle, regardless of the scren resolution.
>
> My first attemp was just using e.Graphics.DpiX and e.Graphics.Pixel but
> after reading I realized that e.Graphics.DpiX has to do with Fonts, not
> the
> actual screen resolution.
>
> I have tried setting the e.Graphics.PageUnit to GraphicsUnit.Inch, and
> then
> looking at the VisibleClipBounds, but this doesn't work either.
>
> Any help would be greatly appreciated.
>
> Thannks.
> mike
>
>


Mike

1/22/2005 2:03:00 AM

0

I have a plug and play monitor, approx 16" x 12", and regardless of the
resolution I set my screen to the Graphics.DpiX and Graphics.DpiY are always
96.

I finally called down to the GDI GetDeviceCaps and got the
HORZSIZE, VERTSIZE, HORZRES, and VERTRES.

Using those I calculated a more accurate DPI, but it was also off as I
lowered my resolution (the native resolution of the screen is 1600x12000)

Finally, I did some news group searching and as far as I can tell, HORZSIZE
and VERTSIZE info is obtained from the device driver, and even with a plug
and play monitor, the system may know the size of the monitor, but the driver
may not.

The only fail-safe solution I have come up with is to add the screen width
and height paramters to the user configuration file and make the user input
them.

Anyway, that is what I figured out.

mike



"Bob Powell [MVP]" wrote:

> Geaphics.Dpi(q) for a screen is the physical screen pixel pitch. You ca
> certainly find the physical size from there on condition thatyou have a plug
> and play monitor that reports its size correctly (some don't)
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tips...
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/f...
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "mike" <mike@discussions.microsoft.com> wrote in message
> news:0CDC6336-5F76-47EA-9251-0CB0EF407939@microsoft.com...
> > Hi,
> >
> > Is there a way to determine the physical size of the client rectangle?
> >
> > i.e. I have a panel i draw to, and I want to know the actual physical size
> > of the rectangle, regardless of the scren resolution.
> >
> > My first attemp was just using e.Graphics.DpiX and e.Graphics.Pixel but
> > after reading I realized that e.Graphics.DpiX has to do with Fonts, not
> > the
> > actual screen resolution.
> >
> > I have tried setting the e.Graphics.PageUnit to GraphicsUnit.Inch, and
> > then
> > looking at the VisibleClipBounds, but this doesn't work either.
> >
> > Any help would be greatly appreciated.
> >
> > Thannks.
> > mike
> >
> >
>
>
>