|
Hbrush HBr;
First:HBr = createsolidbrush (RGB (255, 0, 0 ));// Single color paint brush
Second:HBr = (hbrush) getstockobject (black_brush );// Only paint brushes of specific colors, such as black_brush and gray_brush
Third:HBr = createpatternbrush (hbitmap hbmp );// Obtain the bitmap image brush.
Fourth:HBr = createhatchbrush (INT fnstyle, Colorref clrref)// Create a shadow paint brush
Category 5:HBr = createbrushindirect (logbrush );// Use the logbrush struct to obtain the image brush
Typedef struct taglogbrush { Uint lbstyle;// Painter type Colorref lbcolor;//Color Long lbhatch;// Shadow } Logbrush, * plogbrush;
Sixth:HBr = hbrush createdibpatternbrush (// Create a paint brush using a device-independent bitmap Hglobal hglbdibpacked, // handle to Dib Uint fucolorspec// Color table data );
For example:
Hbrush cafdview: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
Hbrush HBr = cformview: onctlcolor (PDC, pwnd, nctlcolor );
// Todo: change any attributes of the DC here
If (pwnd-> getdlgctrlid () = idc_static1)
{
PDC-> settextcolor (RGB (200,0, 0 ));
PDC-> setbkcolor (RGB (0, 0, 255 ));
Static hbrush = createsolidbrush (RGB (222,0, 255 ));
Return hbrush;
}
// Todo: return a different brush if the default is not desired
Else
Return HBr;
}
Change the background color of the dialog box
Hbrush cd1_dlg: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor)
{
Hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor );
// Todo: change any attributes of the DC here
// Todo: return a different brush if the default is not desired
If (nctlcolor = ctlcolor_dlg)
{
Cbrush * Brush;
Brush = new cbrush (RGB (221,221,221 ));
Return (hbrush) (Brush-> m_hobject );
}
Return HBr;
}
|