Six Methods for image painting (hbrush)

Source: Internet
Author: User
 

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.