我想在一个对话框区域里面画一个矩形的区域,该怎样使用阿,是不是用CBrush,还请高手指点指点阿,

解决方案 »

  1.   

    CClientDC dc(this);
    CRect rc(10,10,80,50);
    dc.FillSolidRect (&rc,RGB(0,0,255));
      

  2.   

    楼上的做法比较简洁,如果用画刷的话就这样:
             CPaintDC dc(this);
    CBrush brush;
    cbrush.CreateSolidBrush(RGB(0,255,0));
    dc.FillRect(CRect(10,10,200,200),&brush);用画刷的话还可以用CreateHatchBrush来创建各种样式的画刷哦.
    比如改成:
       CPaintDC dc(this);
    CBrush cbrush;
    cbrush.CreateHatchBrush(HS_DIAGCROSS,RGB(0,255,0));
    dc.FillRect(CRect(10,10,200,200),&cbrush);
    CreateHatchBrush的第一个参数可以设画刷的样式.
    MSDN:
    BOOL CreateHatchBrush( int nIndex, COLORREF crColor );Return ValueNonzero if successful; otherwise 0.ParametersnIndexSpecifies the hatch style of the brush. It can be any one of the following values: HS_BDIAGONAL   Downward hatch (left to right) at 45 degrees
    HS_CROSS   Horizontal and vertical crosshatch
    HS_DIAGCROSS   Crosshatch at 45 degrees
    HS_FDIAGONAL   Upward hatch (left to right) at 45 degrees
    HS_HORIZONTAL   Horizontal hatch
    HS_VERTICAL   Vertical hatch