all groups > dotnet drawing api > october 2003 >
You're in the

dotnet drawing api

group:

DPI/Large Fonts issues


DPI/Large Fonts issues James Hancock
10/31/2003 11:58:28 PM
dotnet drawing api:
There are a couple of things in the framework that don't handle nicely with
DPI changes (well lots of things but two that I have noticed)

#1 Background graphics on forms tile in large fonts instead of drawing the
graphic larger.
#2 All of the sizing functions are off when looking at graphics. I.e. a 24
pixel graphic is no longer 24 pixels in relation to the newly sized window
for large fonts. Hence if you size yoru control based on the size of a
graphic, the control is VERY small and looks out of place.
#3 Graphics all draw smaller instead of resizing along with everything else
the way they should.

Ok, so that's not such a big deal if we can work around these by getting the
DPI that windows is running in (the screen is running in) but the only
function I can find on this is the DPI of the graphics object, which of
course doesn't cut it. Any ideas on how to get the DPI of windows through
the .net framework so that I can do some math?

Thanks,
James Hancock

RE: DPI/Large Fonts issues JHornick NO[at]SPAM online.microsoft.com
11/1/2003 10:04:27 PM
Hi,

You can get "the DPI" by using GetDeviceCaps() API. However, there are
potentially two DPIs to get - the one returned when you pass LOGPIXELSX/Y,
and the one you'd get if you do the math using HORZRES/SIZE and
VERTRES/SIZE.
See the following article for more info:
http://support.microsoft.com/?id=127152

There's probably some way to tell the form to scale the image rather
than tile it - maybe someone else here knows, or you could post in the
WindowsForms newsgroup. Otherwise, you could simply handle painting
yourself, and stretch the image to fill the ClientRectangle.

The reason your "24pixel graphic" is no longer 24 pixels is because it
never was a 24pixel graphic - it had a real size which happened to map
to 24 pixels a that DPI. Now it maps to a new pixels size in the new DPI.

Similarly, graphics "draw smaller" because they have a real size and
GDI+ is drawing them at the real size, based on the current DPI.

The following article talks about GDI+'s device independence which is
what you're seeing here:
http://support.microsoft.com/?id=311460

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.




[quoted text, click to view]
Re: DPI/Large Fonts issues James Hancock
11/2/2003 3:55:15 PM
Thanks for the info. I was aware why it was doing it, but there are things
that it needs to work around.

The problem is that when a form is scaled so that the new text will fit in
and the controls resized, the images that may have been in there also need
to be resized proportionately otherwise they look way to small, tile or do
other weird and wonderful things. Now it's fine to add this kind of thing on
a control by control basis, but the .net framework should do this
automatically. This is the key reason why Large Fonts is not used by most
people and why most applications look like crap.

The info about GetDeviceCaps() will help me a lot though.

James Hancock

[quoted text, click to view]

AddThis Social Bookmark Button