I followed a MFC program can draw lines, rectangles, curves in the canvys, and can select the pen and brush color and styles, but there's some problem.
first, the menu item check, I don't know why, in the initizlize window, in the
, the
and
2 items are checked, but I use the different brushStyle marco,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
void CSketcherDoc::OnBrushstyleNull()
{
m_BrushStyle = BS_HOLLOW;
}
void CSketcherDoc::OnBSVert()
{
m_BrushStyle = HS_VERTICAL;
}
void CSketcherDoc::OnUpdateBrushstyleNull(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_BrushStyle == BS_HOLLOW);
}
void CSketcherDoc::OnUpdateBSVert(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_BrushStyle == HS_VERTICAL);
}
|
next, I don't understande the moving item code(the
and
functions are implementated)
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void CSketcherView::MoveElement(CClientDC& aDC, const CPoint& point)
{
CSize distance = point - m_CursorPos;
m_CursorPos = point;
if(m_pSelected)
{
aDC.SetROP2(R2_NOTXORPEN);
m_pSelected->Draw(&aDC, m_pSelected); // I don't understand this line
m_pSelected->Move(distance);
m_pSelected->Draw(&aDC, m_pSelected); // draw the moved element
}
}
|
The guide said this line : redraw the selected element in its current color(selected color) to reset it to the background color, and Move()... |
I don't understand this, if I comment this line, when I move one item, it will draw follow the cursor, with this line, it's all ok.
Why redraw the element can make it invisible? I think draw it again will get the same color.
==========================
plus, the program have a little problem, when first click in the client area, it can't draw, only second time click can draw, I don't know what's wrong with it, can you help me look at it?
I uploaded at :
(1.6MB)
=========================
why VS2010 MFC project so huge, almost 100MB each project?