• 画笔与画刷


    声明全局变量

    HPEN hPen[7];
    HBRUSH hBru[7];
    int sPen[7]={PS_SOLID,PS_DASH,PS_DOT,PS_DASHDOT,PS_DASHDOTDOT,
    PS_NULL,PS_INSIDEFRAME};
    int sBru[7]={HS_VERTICAL,HS_HORIZONTAL,HS_CROSS,HS_DIAGCROSS,
    HS_FDIAGONAL,HS_BDIAGONAL};

    void MyPaint(HDC hdc);

    创建画刷与画笔

       for (i=0;i<=6;i++)
       {
        hPen[i] = CreatePen(sPen[i],1,RGB(255,0,0));
        if(i==6)
         hBru[i]=CreateSolidBrush(RGB(0,255,0));
        else
         hBru[i]=CreateHatchBrush(sBru[i],RGB(0,255,0));
       }
       hdc=GetDC(hWnd);
       MyPaint(hdc);
       ReleaseDC(hWnd,hdc);

    关联画刷与画笔并画图

    void MyPaint(HDC hdc)
    {
        int i,x1,x2,y;
     for (i=0;i<=6;i++)
     {
      y=(i+1)*30;
      SelectObject(hdc,hPen[i]);
      MoveToEx(hdc,30,y,NULL);
      LineTo(hdc,100,y);
     }
     x1=120;
     x2=180;

        for (i=0;i<=6;i++)
        {
      SelectObject(hdc,hBru[i]);
      Rectangle(hdc,x1,30,x2,y);
      x1+=70;
      x2+=70;
        }
    }

    删除画刷与画笔

    case WM_DESTROY:
      for (i=0;i<=6;i++)
      {
       DeleteObject(hPen[i]);
       DeleteObject(hBru[i]);
      }
      PostQuitMessage(0);
      break;

  • 相关阅读:
    ASP.Net请求处理机制初步探索之旅
    ASP.Net请求处理机制初步探索之旅
    ASP.Net请求处理机制初步探索之旅
    NET平台处理HTTP请求
    HTTP.SYS
    ASP.NET页面与IIS底层交互和工作原理
    MUI的一些笔记
    SpringMCV跨域
    servlet跨域
    Git
  • 原文地址:https://www.cnblogs.com/batman425/p/3238147.html
Copyright © 2020-2023  润新知