www.gusucode.com > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序 > 《C++高级语言程序设计》PPT及全书例子源代码-源码程序/code/C++例题程序/第8章/s8_11/s8_11View.cpp
//Download by http://www.NewXing.com // s8_11View.cpp : implementation of the CS8_11View class // #include "stdafx.h" #include "s8_11.h" #include "s8_11Doc.h" #include "s8_11View.h" #include "MyDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CS8_11View IMPLEMENT_DYNCREATE(CS8_11View, CView) BEGIN_MESSAGE_MAP(CS8_11View, CView) //{{AFX_MSG_MAP(CS8_11View) ON_COMMAND(ID_SHOW_DIALOG, OnShowDialog) //}}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() ///////////////////////////////////////////////////////////////////////////// // CS8_11View construction/destruction CS8_11View::CS8_11View() { // TODO: add construction code here } CS8_11View::~CS8_11View() { } BOOL CS8_11View::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CS8_11View drawing void CS8_11View::OnDraw(CDC* pDC) { CS8_11Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here pDC->TextOut(pDoc->m_xCoordinate, pDoc->m_yCoordinate, pDoc->m_strShowText); } ///////////////////////////////////////////////////////////////////////////// // CS8_11View printing BOOL CS8_11View::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CS8_11View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CS8_11View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CS8_11View diagnostics #ifdef _DEBUG void CS8_11View::AssertValid() const { CView::AssertValid(); } void CS8_11View::Dump(CDumpContext& dc) const { CView::Dump(dc); } CS8_11Doc* CS8_11View::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CS8_11Doc))); return (CS8_11Doc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CS8_11View message handlers void CS8_11View::OnShowDialog() { // TODO: Add your command handler code here CMyDialog oMyDialog; int iResult = oMyDialog.DoModal(); //显示对话框 if(iResult == IDOK) { //用户单击确定按钮返回 CS8_11Doc *pDoc = GetDocument(); pDoc->m_xCoordinate = oMyDialog.m_xEditCoordinate; pDoc->m_yCoordinate = oMyDialog.m_yEditCoordinate; pDoc->m_strShowText = oMyDialog.m_strEditShowText; Invalidate(); // 使客户区无效,重绘窗客户区 } }