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

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

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




#0244                          InvalidateRect(&rectInvalid); 

#0245                          return; 

#0246                  } 

#0247          } 

#0248          // We can't interpret the hint; so assume that anything might 

#0249          // have been updated。 

#0250          Invalidate(TRUE); 

#0251          return; 

#0252  } 

#0253 

#0254  void CScribbleView::OnInitialUpdate() 

#0255  { 

#0256          SetScrollSizes(MM_LOENGLISH; GetDocument()…》GetDocSize()); 

#0257          CScrollView::OnInitialUpdate(); 

#0258  } 

#0259 



                                                                                        899 


…………………………………………………………Page 962……………………………………………………………

                    第五篇    附錄  



                    #0260  void CScribbleView::OnPrint(CDC* pDC; CPrintInfo* pInfo) 

                    #0261  { 

                    #0262          if (pInfo…》m_nCurPage == 1)  // page no。 1 is the title page 

                    #0263          { 

                    #0264                  PrintTitlePage(pDC; pInfo); 

                    #0265                  return; // nothing else to print on page 1 but the page title 

                    #0266          } 

                    #0267          CString strHeader = GetDocument()…》GetTitle(); 

                    #0268 

                    #0269          PrintPageHeader(pDC; pInfo; strHeader); 

                    #0270          // PrintPageHeader() subtracts out from the pInfo…》m_rectDraw the 

                    #0271          // amount of the page used for the header。 

                    #0272 

                    #0273          pDC…》SetWindowOrg(pInfo…》m_rectDraw。left;…pInfo…》m_rectDraw。top); 

                    #0274 

                    #0275          // Now print the rest of the page 

                    #0276          OnDraw(pDC); 

                    #0277  } 

                    #0278 

                    #0279  void CScribbleView::PrintTitlePage(CDC* pDC; CPrintInfo* pInfo) 

                    #0280  { 

                    #0281          // Prepare a font size for displaying the file name 

                    #0282          LOGFONT logFont; 

                    #0283          memset(&logFont; 0; sizeof(LOGFONT)); 

                    #0284          logFont。lfHeight = 75;  //  3/4th inch high in MM_LOENGLISH 

                    #0285                                                          // (1/100th inch) 

                    #0286          CFont font; 

                    #0287          CFont* pOldFont = NULL; 

                    #0288          if (font。CreateFontIndirect(&logFont)) 

                    #0289                  pOldFont = pDC…》SelectObject(&font); 

                    #0290 

                    #0291          // Get the file name; to be displayed on title page 

                    #0292          CString strPageTitle = GetDocument()…》GetTitle(); 

                    #0293 

                    #0294          // Display the file name 1 inch below top of the page; 

                    #0295          // centered horizontally 

                    #0296          pDC…》SetTextAlign(TA_CENTER); 

                    #0297          pDC…》TextOut(pInfo…》m_rectDraw。right/2; …100; strPageTitle); 

                    #0298 

                    #0299          if (pOldFont != NULL) 

                    #0300                  pDC…》SelectObject(pOldFont); 

                    #0301  } 

                    #0302 

                    #0303  void CScribbleView::PrintPageHeader(CDC* pDC; CPrintInfo* pInfo; 

                    #0304          CString& strHeader) 

                    #0305  { 



900 


…………………………………………………………Page 963……………………………………………………………

                                                   附錄B    Scribble Step5  完整原始碼 



#0306          // Print a page header consisting of the name of 

#0307          // the document and a horizontal line 

#0308          pDC…》SetTextAlign(TA_LEFT); 

#0309          pDC…》TextOut(0;…25; strHeader);  // 1/4 inch down 

#0310 

#0311          // Draw a line across the page; below the header 

#0312          TEXTMETRIC textMetric; 

#0313          pDC…》GetTextMetrics(&textMetric); 

#0314          int y = …35 textMetric。tmHeight;        // line 1/10th inch below text 

#0315          pDC…》MoveTo(0; y);                        // from left margin 

#0316          pDC…》LineTo(pInfo…》m_rectDraw。right; y);    // to right margin 

#0317 

#0318          // Subtract out from the drawing rectange the space used by the header。 

#0319          y …= 25;    // space 1/4 inch below (top of) line 

#0320          pInfo…》m_rectDraw。top += y; 

#0321  } 



PENDLG。H 



#0001  class CPenWidthsDlg : public CDialog 

#0002  { 

#0003  // Construction 

#0004  public: 

#0005          CPenWidthsDlg(CWnd* pParent = NULL);   // standard constructor 

#0006 

#0007  // Dialog Data 

#0008          //{{AFX_DATA(CPenWidthsDlg) 

#0009          enum { IDD = IDD_PEN_WIDTHS }; 

#0010          int             m_nThinWidth; 

#0011          int             m_nThickWidth; 

#0012          //}}AFX_DATA 

#0013 

#0014 

#0015  // Overrides 

#0016          // ClassWizard generated virtual function overrides 

#0017          //{{AFX_VIRTUAL(CPenWidthsDlg) 

#0018          protected: 

#0019          virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 

#0020          //}}AFX_VIRTUAL 

#0021 

#0022  // Implementation 

#0023  protected: 

#0024 

#0025          // Generated message map functions 

#0026          //{{AFX_MSG(CPenWidthsDlg) 

#0027          afx_msg void OnDefaultPenWidths(); 



                                                                                     901 


…………………………………………………………Page 964……………………………………………………………

                   第五篇    附錄  



                   #0028          //}}AFX_MSG 

                   #0029          DECLARE_MESSAGE_MAP() 

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