Two ways to learn the custom brushes of Windows programming day3

Source: Internet
Author: User

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc;    Paintstruct PS;    Rect rect;    Hpen Hpen, hOldPen; Switch(message) { CaseWM_PAINT:HDC= BeginPaint (hwnd, &PS); GetClientRect (hwnd,&rect); //1. Get Brushes//Hpen=getstockobject (Black_pen); //2. Create a new brush yourself//method One://when an image is closed, the middle of the line width is used as the boundary, so it will be more than the desired size (line width size)//Hpen = CreatePen (ps_solid, +, RGB (255,0,0)); //for dashed lines, if the line width is greater than 1, the implementation is displayed, and the style of the original line is invalidated//Hpen = CreatePen (Ps_dash, 0.1, RGB (255, 0, 0)); //Hpen = CreatePen (Ps_dashdot, 0.1, RGB (255, 0, 0)); //Hpen = CreatePen (Ps_dashdotdot, 0.1, RGB (255, 0, 0)); //Used for enclosing images: in the back can be filled border inward compression//Hpen = CreatePen (Ps_insideframe, ten, RGB (255, 0, 0));//Method Two:Logpen pen[Ten];  for(inti =0; I <Ten; i++) {Pen[i].lopnstyle=Ps_solid; pen[i].lopnwidth.x= (i +1) *5; Pen[i].lopncolor= RGB ( -I0,0); }        //set multiple brush styles//Use Createpenindorect to take out the style directly, the code is straightforward and more reusable         for(inti =0; I <Ten; i++) {Hpen= Createpenindirect (&Pen[i]); hOldPen=SelectObject (hdc, hpen); Ellipse (HDC, -+ -*i, -, -+ -*i, $);        DeleteObject (Hpen); }//Movetoex (hdc, Rect.left, (rect.bottom-rect.top)/2, NULL);//LineTo (hdc, Rect.right, (rect.bottom-rect.top)/2); //You can delete only the objects you have defined, and the system does not allow the deletion//DeleteObject (hpen);SelectObject (hdc, hOldPen); EndPaint (hwnd,&PS);  Break;  CaseWm_destroy:postquitmessage (0); return 0; }    returnDefWindowProc (hwnd, message, WParam, LParam);}

Two ways to learn the custom brushes of Windows programming day3

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.