CBrush Brush, *poldbrush;
Brush.createsolidbrush (hs_bdiagonal, RGB (255, 0, 0));
Poldbrush = PDC->selectobject (&brush);
The intent of the above code is to create a brush, select the device context; Unfortunately, when creating a brush is wrong, the number of parameters is a problem, here and create a brush, when creating a brush to define three parameters: format, width, color; creating a brush simply defines the color.
Create a brush and customize it
Code
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width ()/2,-rect. Height ()/2);
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);
Rect. Offsetrect (-rect. Width ()/2,-rect. Height ()/2);
CRect rect1 (CPoint ( -100), CPoint (100, 100));
CRect Rect2 (CPoint ( -100, -100), CPoint (100,-50));
CBrush Brush (Hs_bdiagonal,rgb (255, 0, 0));
CBrush *poldbrush = PDC->selectobject (&brush);
PDC->fillrect (Rect1, &brush);
PDC->fillsolidrect (Rect2, RGB (255, 0, 0));
PDC->selectobject (Poldbrush);
From the above know the definition and selection of painting brush
CBrush Brush (Hs_bdiagonal,rgb (255, 0, 0));
CBrush *poldbrush = PDC->selectobject (&brush);
Brushes and paint brushes