喜 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;
答案 0 :(得分: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);
}
编辑:好的,如果你确实坚持认为它必须是洪水填充,并且你是在响应按钮点击而做的,你可能会这样做:< / p>
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);
}