CDC帮助为对象着色

嗨 C ++ Visual Studio CDC :: ExtFloodFill中有一个函数(int x,int y,COLORREF crColor,UINT nFillType); 我的问题是我们想要代替的 int x,int y,COLORREF crColor,UINT nFillType 就像我有一个我想要颜色的对象如何做到这一点
enter code here
                 #include "afxwin.h"

    class fr : public CFrameWnd
             {

               public:

CPoint st;
CPoint en;

fr()
{

    Create(0,"First Frame");
}


//////////////////////
void OnLButtonDown(UINT fl,CPoint p )

{
    st.x=p.x;
    st.y=p.y;
}

//////////////////////
void OnLButtonUp(UINT fl,CPoint r)
{

    en.x=r.x;
    en.y=r.y;




    CClientDC d(this);

    d.Ellipse(st.x,st.y,en.x,en.y);

      }
      void OnRButtonDown(UINT fl,CPoint q)
      {
        CClientDC e(this);


    e.ExtFloodFill(............);
      }
    DECLARE_MESSAGE_MAP()
 };
    BEGIN_MESSAGE_MAP(fr,CFrameWnd)
ON_WM_LBUTTONDOWN()
    ON_WM_RBUTTONDOWN()
    END_MESSAGE_MAP()

   class app : public CWinApp
 {


    public:
int InitInstance()
{   

    fr*sal;
    sal=new fr;
    m_pMainWnd=sal;
    sal->ShowWindow(1);

    return true;
}

  };

  app a;
    
已邀请:
对于您的示例,ExtFloodFill(或任何其他版本的FloodFill)并不是真正的正确选择。 相反,您通常希望将当前画笔设置为所需的颜色/图案,然后绘制您的对象(它将自动填充当前画笔)。例如,假设您要绘制一个红色椭圆:
CMyView::OnDraw(CDC *pDC) { 
    CBrush red_brush;

    red_brush.CreateSolidBrush(RGB(255, 0, 0));

    pDC->SelectObject(red_brush);
    pDC->Ellipse(0, 0, 100, 50);
}
编辑:好的,如果你真的坚持它必须是洪水填充,而你是在响应按钮点击它,你可能会做这样的事情:
void CYourView::OnRButtonDown(UINT nFlags, CPoint point)
{
    CClientDC dc(this);
    CBrush blue_brush;
    blue_brush.CreateSolidBrush(RGB(0, 0, 255));
    dc.SelectObject(blue_brush);
    dc.ExtFloodFill(point.x, point.y, RGB(0, 0,0), FLOODFILLBORDER);
    CView::OnRButtonDown(nFlags, point);
}
    

要回复问题请先登录注册