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;
hi
There is a function in C++ Visual studio CDC::ExtFloodFill(int x, int y, COLORREF crColor,UINT nFillType);
my question is that what we suppose to write in place of
int x , int y, COLORREF crColor, UINT nFillType
Like if I have a Object Which I want to Color How to do it
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您的示例,ExtFloodFill(或 FloodFill 的任何其他版本)实际上并不是正确的选择。
相反,您通常希望将当前画笔设置为您想要的颜色/图案,然后绘制对象(并且它将自动用当前画笔填充)。例如,假设您想绘制一个红色椭圆:
编辑:好的,如果您真的坚持它必须是洪水填充,并且您这样做是为了响应按钮点击,你可能会做这样的事情:
For your example, ExtFloodFill (or any other version of FloodFill) isn't really the right choice.
Instead, you normally want to set the current brush to the color/pattern you want, then draw your object (and it'll automatically be filled with the current brush). Let's say, for example, that you want to draw a red ellipse:
Edit: Okay, if you really insist it has to be a flood-fill, and you're doing it in response to a button click, you'd probably do something like this: