DC functions, canvas methods

The Windows Way of performing graphics operations is to provide every sort of function you can imagine for every operation, no matter how obscure. The Basic Way is to provide the most important graphics operations through a few methods loaded with optional arguments. The Line method, for example, wraps up the functionality of several API functions. Table 7-3 compares device context functions in Windows with canvas methods in Visual Basic.

Operation Windows Way Basic Way
Point drawing SetPixel PSet
Point reading GetPixel Point
Line drawing LineTo and MoveToEx Line method or Line control
Circle, pie, and arc drawing Ellipse, Chord, Arc, and Pie Circle method or Shape control
Polygon drawing Polygon, PolyPolygon, and SetPolyFillMode Draw it line by line
Blitting BitBlt, StretchBlt, PatBlt, and StretchDIBits PaintPicture method, Image control with Stretch property
Filling shapes FloodFill and other Fill functions Visual Basic can create filled shapes but has no way of filling shapes later
Icon painting LoadIcon, CreateIcon, Destroy-Icon, and DrawIcon Picture object
Bitmap painting Various Bitmap functions and SelectObject Picture object
Metafile recording CreateMetaFile and CloseMetaFile No way
Metafile playing CopyMetaFile, GetMetafile, and DeleteMetaFile functions Picture object
Scrolling ScrollDC No way
Managing regions Various Rgn and Path functions No way
Printing Escape and Doc functions Methods on Print object
Text output Many functions including Text-Out, ExtTextOut, and GrayString Print
Text sizing GetTextExtent TextWidth and TextHeight
Text alignment SetTextAlign, SetTextJustification, and SetTextCharacterExtra functions No way

Table 7-3. Graphics methods in Windows and in Visual Basic.

To the hardcore programmer, what Visual Basic doesn’t do is more telling than what it does. Some points of interest: