Chapter 4. Drawing Basics


As handy as forms are, especially when laden with controls, sometimes the built-in controls [1] aren't sufficient to render the state of your application. In that case, you need to draw the state yourself. The drawing may be to the screen, to a file, or to a printer, but wherever you're drawing to, you'll be dealing with the same primitives ”colors, brushes, pens, and fonts ”and the same kinds of things to draw: shapes , images, and strings. This chapter starts by examining the basics of drawing to the screen and the basic building blocks of drawing.

[1] The standard controls that come with WinForms are listed in Appendix D: Standard WinForms Components and Controls.

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

One more thing worth noting before we begin is 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's orders of magnitude easier than supporting printers and video display adapters by hand, which was what DOS programmers had to do to put bread on the table.



Windows Forms Programming in Visual Basic .NET
Windows Forms Programming in Visual Basic .NET
ISBN: 0321125193
EAN: 2147483647
Year: 2003
Pages: 139

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