www.gusucode.com > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序 > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序/code/C++例题程序/第10章/s10_2_3/s10_2View.cpp
//Download by http://www.NewXing.com // s10_2View.cpp : implementation of the CS10_2View class // #include "stdafx.h" #include "s10_2.h" #include "s10_2Doc.h" #include "s10_2View.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CS10_2View IMPLEMENT_DYNCREATE(CS10_2View, CView) BEGIN_MESSAGE_MAP(CS10_2View, CView) //{{AFX_MSG_MAP(CS10_2View) ON_WM_LBUTTONDBLCLK() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CS10_2View construction/destruction CS10_2View::CS10_2View() { // TODO: add construction code here } CS10_2View::~CS10_2View() { } BOOL CS10_2View::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CS10_2View drawing void CS10_2View::OnDraw(CDC* pDC) { CS10_2Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CS10_2View printing BOOL CS10_2View::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CS10_2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CS10_2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CS10_2View diagnostics #ifdef _DEBUG void CS10_2View::AssertValid() const { CView::AssertValid(); } void CS10_2View::Dump(CDumpContext& dc) const { CView::Dump(dc); } CS10_2Doc* CS10_2View::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CS10_2Doc))); return (CS10_2Doc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CS10_2View message handlers void CS10_2View::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CClientDC oDC(this); // oDC为当前客户区 CPen oPen(PS_DOT, 1, RGB(0, 0, 255)); // 创建画笔 CPen *pOldPen; // 定义旧画笔指针 pOldPen = oDC.SelectObject(&oPen); // 选择画笔 CRect oRectangle; // 矩形对象 GetClientRect(&oRectangle); // 获得当前客户区边界的矩形对象 oDC.Ellipse(oRectangle); // 画一个椭圆 oDC.SelectObject(pOldPen); // 还原画笔 CView::OnLButtonDblClk(nFlags, point); }