class CEx05aView : public CScrollView
{
CRect m_rectEllipse;
int m_nColor;
protected: // create from serialization only
CEx05aView();
...
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEx05aView)
public:
...
virtual void OnInitialUpdate();
//}}AFX_VIRTUAL
...
// Generated message map functions
protected:
//{{AFX_MSG(CEx05aView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CEx05aView::CEx05aView()
: m_rectEllipse(0, 0, 4000, -4000)
//: m_rectEllipse(0, 0, 200, 200)
{
// TODO: add construction code here
m_nColor = GRAY_BRUSH;
}
...
void CEx05aView::OnDraw(CDC* pDC)
{
/*
CEx05aDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); */
// TODO: add draw code for native data here
pDC->SelectStockObject(m_nColor);
pDC->Ellipse(m_rectEllipse);
}
...
void CEx05aView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CSize sizeTotal(20000, 30000); // 20x30 cm
CSize sizePage(sizeTotal.cx / 2, sizeTotal.cy / 2);
CSize sizeLine(sizeTotal.cx / 50, sizeTotal.cy / 50);
SetScrollSizes(MM_HIMETRIC, sizeTotal, sizePage, sizeLine);
}
void CEx05aView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
OnPrepareDC(&dc);
CRect rectDevice = m_rectEllipse;
dc.LPtoDP(rectDevice);
if (rectDevice.PtInRect(point)) {
if (m_nColor == GRAY_BRUSH){
m_nColor = WHITE_BRUSH;
}
else {
m_nColor = GRAY_BRUSH;
}
InvalidateRect(rectDevice);
}
// CScrollView::OnLButtonDown(nFlags, point);
}