程序代码如下:
void CSigleView::OnDraw(CDC* pDC)
{
CSigleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush NewBrush;
CBrush *OldBrush;
pDC->Rectangle(100,400,200,500); //画矩形
NewBrush.CreateSolidBrush(RGB(0,0,0)); //初始化画刷
OldBrush = pDC->SelectObject(&NewBrush);
pDC->FloodFill(100,400,RGB(0,0,0)); //给矩形填充颜色
pDC->SelectObject(OldBrush);
}
3 个解决方案
#1
你的坐标可能没有对准。参看以下代码:
CColorDialog dlg;
COLORREF m_SpecularColor;
if(rect.PtInRect(point))
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
m_SpecularColor= dlg.GetColor();
InvalidateRect(&rect,FALSE);
}
}
CBrush SpecularBrush(m_SpecularColor);
dc.FillRect(&rect,&SpecularBrush);
CColorDialog dlg;
COLORREF m_SpecularColor;
if(rect.PtInRect(point))
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
m_SpecularColor= dlg.GetColor();
InvalidateRect(&rect,FALSE);
}
}
CBrush SpecularBrush(m_SpecularColor);
dc.FillRect(&rect,&SpecularBrush);
#2
pDC->FloodFill(100,400,RGB(0,0,0)); //给矩形填充颜色
改成
pDC->FloodFill(101,401,RGB(0,0,0)); //给矩形填充颜色
试试看?
改成
pDC->FloodFill(101,401,RGB(0,0,0)); //给矩形填充颜色
试试看?
#3
void CSigleView::OnDraw(CDC* pDC)
{
CSigleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush NewBrush;
CBrush *OldBrush;
NewBrush.CreateSolidBrush(RGB(0,0,0)); //初始化画刷
OldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(100,400,200,500); //画矩形
pDC->SelectObject(OldBrush);
}
it's ok
{
CSigleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush NewBrush;
CBrush *OldBrush;
NewBrush.CreateSolidBrush(RGB(0,0,0)); //初始化画刷
OldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(100,400,200,500); //画矩形
pDC->SelectObject(OldBrush);
}
it's ok
#1
你的坐标可能没有对准。参看以下代码:
CColorDialog dlg;
COLORREF m_SpecularColor;
if(rect.PtInRect(point))
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
m_SpecularColor= dlg.GetColor();
InvalidateRect(&rect,FALSE);
}
}
CBrush SpecularBrush(m_SpecularColor);
dc.FillRect(&rect,&SpecularBrush);
CColorDialog dlg;
COLORREF m_SpecularColor;
if(rect.PtInRect(point))
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
m_SpecularColor= dlg.GetColor();
InvalidateRect(&rect,FALSE);
}
}
CBrush SpecularBrush(m_SpecularColor);
dc.FillRect(&rect,&SpecularBrush);
#2
pDC->FloodFill(100,400,RGB(0,0,0)); //给矩形填充颜色
改成
pDC->FloodFill(101,401,RGB(0,0,0)); //给矩形填充颜色
试试看?
改成
pDC->FloodFill(101,401,RGB(0,0,0)); //给矩形填充颜色
试试看?
#3
void CSigleView::OnDraw(CDC* pDC)
{
CSigleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush NewBrush;
CBrush *OldBrush;
NewBrush.CreateSolidBrush(RGB(0,0,0)); //初始化画刷
OldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(100,400,200,500); //画矩形
pDC->SelectObject(OldBrush);
}
it's ok
{
CSigleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush NewBrush;
CBrush *OldBrush;
NewBrush.CreateSolidBrush(RGB(0,0,0)); //初始化画刷
OldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(100,400,200,500); //画矩形
pDC->SelectObject(OldBrush);
}
it's ok