友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!阅读过程发现任何错误请告诉我们,谢谢!! 报告错误
狗狗书籍 返回本书目录 我的书架 我的书签 TXT全本下载 进入书吧 加入书签

深入浅出MFC第2版(PDF格式)-第293章

按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!




                                                   附錄B    Scribble Step5  完整原始碼 



#0030  ///////////////////////////////////////////////////////////////// 

#0031  // CScribbleView construction/destruction 

#0032 

#0033  CScribbleView::CScribbleView() 

#0034  { 

#0035          // TODO: add construction code here 

#0036 

#0037  } 

#0038 

#0039  CScribbleView::~CScribbleView() 

#0040  { 

#0041  } 

#0042 

#0043  BOOL CScribbleView::PreCreateWindow(CREATESTRUCT& cs) 

#0044  { 

#0045          // TODO: Modify the Window class or styles here by modifying 

#0046          //  the CREATESTRUCT cs 

#0047 

#0048          return CView::PreCreateWindow(cs); 

#0049  } 

#0050 

#0051  //////////////////////////////////////////////////////////////// 

#0052  // CScribbleView drawing 

#0053 

#0054  void CScribbleView::OnDraw(CDC* pDC) 

#0055  { 

#0056          CScribbleDoc* pDoc = GetDocument(); 

#0057          ASSERT_VALID(pDoc); 

#0058 

#0059          // Get the invalidated rectangle of the view; or in the case 

#0060          // of printing; the clipping region of the printer dc。 

#0061          CRect rectClip; 

#0062          CRect rectStroke; 

#0063          pDC…》GetClipBox(&rectClip); 

#0064          pDC…》LPtoDP(&rectClip); 

#0065          rectClip。InflateRect(1; 1); // avoid rounding to nothing 

#0066 

#0067          // Note: CScrollView::OnPaint() will have already adjusted the 

#0068          // viewport origin before calling OnDraw(); to reflect the 

#0069          // currently scrolled position。 

#0070 

#0071          // The view delegates the drawing of individual strokes to 

#0072          // CStroke::DrawStroke()。 

#0073          CTypedPtrList& strokeList = pDoc…》m_strokeList; 

#0074          POSITION pos = strokeList。GetHeadPosition(); 

#0075          while (pos != NULL) 



                                                                                     895 


…………………………………………………………Page 958……………………………………………………………

                   第五篇    附錄  



                    #0076          { 

                    #0077                  CStroke* pStroke = strokeList。GetNext(pos); 

                    #0078                  rectStroke = pStroke…》GetBoundingRect(); 

                    #0079                  pDC…》LPtoDP(&rectStroke); 

                    #0080                  rectStroke。InflateRect(1; 1); // avoid rounding to nothing 

                    #0081                  if (!rectStroke。IntersectRect(&rectStroke; &rectClip)) 

                    #0082                          continue; 

                    #0083                  pStroke…》DrawStroke(pDC); 

                    #0084          } 

                    #0085  } 

                    #0086 

                    #0087  ///////////////////////////////////////////////////////////////// 

                    #0088  // CScribbleView printing 

                    #0089 

                    #0090  BOOL CScribbleView::OnPreparePrinting(CPrintInfo* pInfo) 

                    #0091  { 

                    #0092          pInfo…》SetMaxPage(2);   // the document is two pages long: 

                    #0093                                     // the first page is the title page 

                    #0094                                     // the second is the drawing 

                    #0095          BOOL bRet = DoPreparePrinting(pInfo);   // default preparation 

                    #0096          pInfo…》m_nNumPreviewPages = 2;  // Preview 2 pages at a time 

                    #0097          // Set this value after calling DoPreparePrinting to override 

                    #0098          // value read from 。INI file 

                    #0099          return bRet; 

                    #0100  } 

                    #0101 

                    #0102  void CScribbleView::OnBeginPrinting(CDC* /*pDC*/; CPrintInfo* /*pInfo*/) 

                    #0103  { 

                    #0104          // TODO: add extra initialization before printing 

                    #0105  } 

                    #0106 

                    #0107  void CScribbleView::OnEndPrinting(CDC* /*pDC*/; CPrintInfo* /*pInfo*/) 

                    #0108  { 

                    #0109          // TODO: add cleanup after printing 

                    #0110  } 

                    #0111 

                    #0112  /////////////////////////////////////////////////////////////// 

                    #0113  // CScribbleView diagnostics 

                    #0114 

                    #0115  #ifdef _DEBUG 

                    #0116  void CScribbleView::AssertValid() const 

                    #0117  { 

                    #0118          CScrollView::AssertValid(); 

                    #0119  } 

                    #0120 

                    #0121  void CScribbleView::Dump(CDumpContext& dc) const 



896 


…………………………………………………………Page 959……………………………………………………………

                                                    附錄B    Scribble Step5  完整原始碼 



#0122  { 

#0123          CScrollView::Dump(dc); 

#0124  } 

#0125 

#0126  CScribbleDoc* CScribbleView::GetDocument() // non…debug version is inline 

#0127  { 

#0128          ASSERT(m_pDocument…》IsKindOf(RUNTIME_CLASS(CScribbleDoc))); 

#0129          return (CScribbleDoc*)m_pDocument; 

#0130  } 

#0131  #endif //_DEBUG 

#0132 

#0133  ///////////////////////////////////////////////////////////////// 

#0134  // CScribbleView message handlers 

#0135 

#0136  void CScribbleView::OnLButtonDown(UINT; CPoint point) 

#0137  { 

#0138      // Pressing the mouse button in the view window starts a new stroke 

#0139 

#0140          // CScrollView changes the viewport origin and mapping mode。 

#0141          // It's necessary to convert the point from device coordinates 

#0142          // to logical coordinates; such as are stored in the document。 

#0143          CClientDC dc(this); 

#0144          OnPrepareDC(&
返回目录 上一页 下一页 回到顶部 0 0
未阅读完?加入书签已便下次继续阅读!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!