Chapter 5. Drawing Basics


5. Drawing Basics

As handy as forms are and as rich as the set of built-in controls is, sometimes neither is sufficient to render the state of your application.[1] In that case, you need to draw the state yourself. You may be drawing to the screen, to a file, or to a printer, but wherever you're drawing to, you're dealing with the same primitivescolors, brushes, pens, and fontsand the same kinds of things to draw: shapes, images, and strings. This chapter starts by examining the fundamentals of drawing to the screen and the basic building blocks of drawing.

[1] The standard controls that come with Windows Forms are listed in Appendix D: Component and Control Survey.

Note that all the drawing techniques discussed in this chapter and in the next two chapters relate equally well to controls as to forms. For information about building custom controls, see Chapter 10: Controls.

Also note that the System.Drawing namespace is implemented on top of GDI+ (Graphics Device Interface+), the successor to GDI. The original GDI has been a mainstay in Windows since there was a Windows, providing an abstraction over screens and printers to make writing GUI-style applications easy.[2] GDI+ is a Win32 DLL (gdiplus.dll) that ships with Windows XP and is available for older versions of Windows. GDI+ is also an unmanaged C++ class library that wraps gdiplus.dll. Because the System.Drawing classes share many of the same names with the GDI+ C++ classes, you may very well stumble onto the unmanaged classes when looking for the .NET classes in the online documentation. The concepts are the same, but the coding details are very different between unmanaged C++ and managed anything else, so keep an eye out.

[2] GDI programming certainly isn't easy when compared with System.Drawing programming, but it is tremendously easier than supporting printers and video display adapters by hand, something DOS programmers had to do to put food on the table.




Windows Forms 2.0 Programming
Windows Forms 2.0 Programming (Microsoft .NET Development Series)
ISBN: 0321267966
EAN: 2147483647
Year: 2006
Pages: 216

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net