Page Units

So far, we've been concentrating on drawing to the screen. By default, if you're drawing in the Paint event handler, you're drawing in units of pixels. Even if you create a graphics object from a form using Form.CreateGraphics, you'll be drawing in units of pixels. This is handy because the units of the user interface elements, such as the client rectangle and the position and sizes of the controls, are all in pixels.

Pixels translate into real-world coordinates based on system settings for Normal or Small versus Large or Custom fonts, the resolution at which the display adapter is running, and the size of the monitor. Taking all that into account, only some of which is available programmatically, it would be remarkably difficult to ...

Get Windows Forms Programming in C# now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.