6. Use a paint brush to change the line color and type:
Cpen pen (ps_dot, 1, RGB (0,255, 0); // constructs a paint brush object
Cclientdc DC (this); cpen * poldpen = Dc. SelectObject (& pen); // select the brush into the DC
DC. moveTo (m_ptorigin );
DC. lineto (point );
DC. SelectObject (poldpen); // restore the previous paint brush
7. Use a paint brush (usually fill the rectangular area with a paint brush ):
Use a monochrome paint brush
Cbrush brush (RGB (255, 0, 0); // construct a paint brush object
Cclientdc DC (this );
DC. fillrect (crect (m_ptorigin, point), & brush); // fill the rectangular area with the specified paint brush
Use bitmap painter
Cbitmap bitmap; // construct a bitmap object (trial is required before use)
Bitmap. loadbitmap (idb_bitmap1); // The first bitmap object.
Cbrush brush (& Bitmap); // constructs a bitmap brush.
Cclientdc DC (this );
DC. fillrect (crect (m_ptorigin, point), & brush); // fill the rectangular area with the specified bit image
Use a transparent image brush
Cbrush * pbrush = cbrush: fromhandle (hbrush) getstockobject (null_brush); // obtain the pointer of a transparent image brush object
Cclientdc DC (this );
Cbrush * poldbrush = Dc. SelectObject (pbrush); // select DC for transparent image painting.
DC. rectangle (crect (m_ptorigin, point ));
DC. SelectObject (poldbrush); // release the transparent paint brush
Note:
The getstockobject function retrieves a handle to one of the predefined stock pens, brushes, fonts, or palettes.
Hgdiobj getstockobject (
Int fnobject // type of stock object
);
Returns a pointer to a cbrush object when given a handle to a Windows hbrush object.
Static cbrush * Pascal fromhandle (hbrush); // fromhandle is a static method, so it can be called in the form of cbrush: fromhandle.