The method of drawing brush of Win32

Source: Internet
Author: User

Six ways to draw brushes (hbrush) 2009- -- at  the: 00HBRUSH HBR; the first type: HBR= CreateSolidBrush (RGB (255,0,0));//Monochrome Paint BrushThe second kind: hbr= (hbrush) getstockobject (Black_brush);//can only take a specific color of the brush, such as Black_brush,gray_brush brushThe Third Kind: hbr= CreatePatternBrush (Hbitmap hbmp);//get a bit drawing brushFourth type: HBR = Createhatchbrush (intFnstyle, COLORREF Clrref)//Create a shaded paint brushFifth type: hbr= createbrushindirect (Logbrush);//drawing Brushes by Logbrush structure bodytypedefstructTaglogbrush {UINT lbstyle;//Paint Brush TypeCOLORREF Lbcolor;//ColorLONG Lbhatch;//Shadows} logbrush, *Plogbrush; The sixth type: HBR= Hbrush CreateDIBPatternBrush (//Create a brush with a device-independent bitmapHglobal hglbdibpacked,//Handle to DIBUINT 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 DCif(Pwnd->getdlgctrlid () = =Idc_static1) {PDC->settextcolor (RGB ( $,0,0));pD C->setbkcolor (RGB (0,0,255));StaticHbrush hbrush = CreateSolidBrush (RGB (222,0,255));returnHbrush;}//Todo:return A different brush if the default is not desiredElse returnHBR;} Change dialog box background color hbrush cdqfdlg::onctlcolor (CDC* PDC, cwnd*pWnd, UINT nCtlColor) {Hbrush HBR=Cdialog::onctlcolor (PDC, PWnd, nCtlColor);//todo:change Any attributes of the DC//Todo:return A different brush if the default is not desiredif(nCtlColor = =Ctlcolor_dlg) {CBrush*Brush;brush=NewCBrush (RGB (221,221,221));return(Hbrush) (brush->m_hobject);}returnHBR;}

The first method and the second method are self-tested and can be used, followed by no tests.

The method of drawing brush of Win32

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.