home *** CD-ROM | disk | FTP | other *** search
- // circlvw.cpp : implementation of the CCircleitView class
- //
-
- #include "stdafx.h"
- #include "circleit.h"
-
- #include "circldoc.h"
- #include "circlvw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView
-
- IMPLEMENT_DYNCREATE(CCircleitView, CView)
-
- BEGIN_MESSAGE_MAP(CCircleitView, CView)
- //{{AFX_MSG_MAP(CCircleitView)
- ON_WM_LBUTTONDOWN()
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView construction/destruction
-
- CCircleitView::CCircleitView()
- {
- // TODO: add construction code here
- }
-
- CCircleitView::~CCircleitView()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView drawing
-
- void CCircleitView::OnDraw(CDC* pDC)
- {
- CCircleitDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- CString MyString =
- "Push the left button of the mouse to draw a circle";
-
- pDC->TextOut( 10,
- 20,
- MyString );
-
-
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView printing
-
- BOOL CCircleitView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
-
- void CCircleitView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
-
- void CCircleitView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView diagnostics
-
- #ifdef _DEBUG
- void CCircleitView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CCircleitView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CCircleitDoc* CCircleitView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCircleitDoc)));
- return (CCircleitDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CCircleitView message handlers
-
- void CCircleitView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- CDC* pDC = GetDC();
-
- // Create a new pen
- CPen NewPen (PS_SOLID, // The Style
- 10, // The width
- RGB(255, 0, 0) ); // The color
-
- // Set the new pen (and save the original pen)
- CPen* pOriginalPen = pDC->SelectObject ( &NewPen );
-
-
- // Create a rectangle object
- CRect theRect ( point.x-20,
- point.y-20,
- point.x+20,
- point.y+20 );
-
- // Draw the Circle
- pDC->Ellipse ( &theRect );
-
- // Restore the original pen
- pDC->SelectObject ( pOriginalPen );
-
-
- ReleaseDC (pDC);
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- CView::OnLButtonDown(nFlags, point);
- }
-