| | | | Note, however, that in the examples in the following discussion of GDI drawing, we will use a picture box whose AutoRedraw property is set to False, but we will not bother to place the drawing code in the Paint event for these examples. | | | | | | The Picture and Image properties and the CLS method | | | | | | By definition, the Picture property of a VB control always returns a handle to the background bitmap for the window. On the other hand, the Image property is intended to return a handle to the persistent bitmap. If this bitmap does not exist, then VB creates a persistent bitmap containing the same image as the background bitmap (but this is a different bitmap). The Image property then returns a handle to the newly created persistent bitmap. | | | | | | Finally, we mention that the Visual Basic Cls method is based on the hDC property. Thus, when AutoRedraw is True, the persistent bitmap is cleared to the background color, and this change is also reflected in the window. When AutoRedraw is False, the window is cleared directly, and the persistent bitmap is drawn in that window. | | | | | | Pens are graphic objects used to draw lines and curves. Many drawing functions require pens. For instance, the LineTo function is: | | | | | | BOOL LineTo( HDC hdc, // device context handle int nXEnd, // x-coordinate of line's ending point int nYEnd // y-coordinate of line's ending point ); | | | | | | This function draws a line using the pen that is currently selected into the device context. | | | | | | The Windows GDI supports two types of pens: cosmetic and geometric. | | | | | | A cosmetic pen is used for quick drawing operations. Cosmetic pens use fewer resources than geometric pens, but have only three attributes: width, style, and color. | | | | | | The functions CreatePen, CreatePenIndirect, or ExtCreatePen can be used to create a cosmetic pen. Windows also maintains three stock cosmetic pens, denoted by BLACK_PEN,WHITE_PEN, and DC_PEN (Windows 98/2000 only), which are accessible using the GetStockObject function. | | | | | | The CreatePen function is: | | | | | | HPEN CreatePen( int fnPenStyle, // pen style | | |