0

您好 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;
4

1 回答 1

0

对于您的示例,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);
}
于 2011-04-08T18:03:35.603 回答