嗔秤戻幣�哉膵�云利匈嬉蝕湊蛸賜�塋床四衲���萩晦編報炎嘔囚^泡仟 ̄云利匈��
源平慎弌傍利 卦指云慕朕村 紗秘慕禰 厘議慕尺 厘議慕禰 TXT畠云和墮 〆辺茄欺厘議箝誓匂〇

侮秘燃竃MFC及2井(PDF鯉塀)-及118何蛍

酔楯荷恬: 梓囚徒貧圭�鮗� ○ 賜 ★ 辛酔堀貧和鍬匈 梓囚徒貧議 Enter 囚辛指欺云慕朕村匈 梓囚徒貧圭�鮗� ● 辛指欺云匈競何! 泌惚云慕短嗤堋響頼���誅卒亮茂�俊彭堋響��辛聞喘貧圭 "辺茄欺厘議箝誓匂" 孔嬬 才 "紗秘慕禰" 孔嬬��



                    #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  頼屁圻兵�a 



#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��&dc���察�

#0145          dc。DPtoLP��&point���察�

#0146 

#0147          m_pStrokeCur = GetDocument�┌�´〃NewStroke�┌��察�

#0148          // Add first point to the new stroke 

#0149          m_pStrokeCur´〃m_pointArray。Add��point���察�

#0150 

#0151          SetCapture�┌��察      �// Capture the mouse until button up。 

#0152          m_ptPrev = point�察  �// Serves as the MoveTo�┌� anchor point for the 

#0153                                // LineTo�┌� the next point�察�as the user drags the 

#0154                                // mouse。 

#0155 

#0156          return�察�

#0157  �� 

#0158 

#0159  void CScribbleView�今�OnLButtonUp��UINT�察�CPoint point�� 

#0160  �� 

#0161          // Mouse button up is interesting in the Scribble application 

#0162          // only if the user is currently drawing a new stroke by dragging 

#0163          // the captured mouse。 

#0164 

#0165          if ��GetCapture�┌� ��= this�� 

#0166                  return�察�// If this window ��view�� didn't capture the mouse�察�

#0167                                  // then the user isn't drawing in this window。 



                                                                                       897 


´´´´´´´´´´´´´´´´´´´´´´Page 960´´´´´´´´´´´´´´´´´´´´´´´

                   及励鐙    現��  



                   #0168 

                   #0169          CScribbleDoc* pDoc = GetDocument�┌��察�

                   #0170 

                   #0171          CClientDC dc��this���察�

                   #0172 

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

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

                   #0175          // to logical coordinates�察�such as are stored in the document。 

                   #0176          OnPrepareDC��&dc���察 �// set up mapping mode and viewport origin 

                   #0177          dc。DPtoLP��&point���察�

                   #0178 

                   #0179          CPen* pOldPen = dc。SelectObject��pDoc´〃GetCurrentPen�┌����察�

                   #0180          dc。MoveTo��m_ptPrev���察�

                   #0181          dc。LineTo��point���察�

                   #0182          dc。SelectObject��pOldPen���察�

                   #0183          m_pStrokeCur´〃m_pointArray。Add��point���察�

                   #0184 

                   #0185          // Tell the stroke item that we're done adding points to it。 

                   #0186          // This is so it can finish puting its bounding rectangle。 

                   #0187          m_pStrokeCur´〃FinishStroke�┌��察�

                   #0188 

                   #0189          // Tell the other views that this stroke has been added 

                   #0190          // so that they can invalidate this stroke's area in their 

                   #0191          // client area。 

                   #0192          pDoc´〃UpdateAllViews��this�察�0L�察�m_pStrokeCur���察�

                   #0193 

                   #0194          ReleaseCapture�┌��察  �// Release the mouse capture established at 

                   #0195                                 // the beginning of the mouse drag。 

                   #0196          return�察�

                   #0197  �� 

                   #0198 

                   #0199  void CScribbleView�今�OnMouseMove��UINT�察�CPoint point�� 

                   #0200  �� 

                   #0201          // Mouse movement is interesting in the Scribble application 

                   #0202          // only if the user is currently drawing a new stroke by dragging 

                   #0203          // the captured mouse。 

                   #0204 

                   #0205          if ��GetCapture�┌� ��= this�� 

                   #0206                  return�察�// If this window ��view�� didn't capture the mouse�察�

                   #0207                             // then the user isn't drawing in this window。 

                   #0208 

                   #0209          CClientDC dc��this���察�

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

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

                   #0212          // to logical coordinates�察�such as are stored in the document。 

                   #0213          OnPrepareDC��&dc���察�



898 


´´´´´´´´´´´´´´´´´´´´´´Page 961´´´´´´´´´´´´´´´´´´´´´´´

                                                     現��B    Scribble Step5  頼屁圻兵�a 



#0214          dc。DPtoLP��&point���察�

#0215 

#0216          m_pStrokeCur´〃m_pointArray。Add��point���察�

#0217 

#0218          // Draw a line from the previous detected point in the mouse 

#0219          // drag to the current point。 

#0220          CPen* pOldPen = dc。SelectObject��GetDocument�┌�´〃GetCurrentPen�┌����察�

#0221          dc。MoveTo��m_ptPrev���察�

#0222          dc。LineTo��point���察�

#0223          dc。SelectObject��pOldPen���察�

#0224          m_ptPrev = point�察�

#0225          return�察�

#0226  �� 

#0227 

#0228  void CScribbleView�今�OnUpdate��CView* /* pSender */�察�LPARAM /* lHint */�察�

#0229          CObject* pHint�� 

#0230  �� 

#0231          // The document has informed this view that some data has changed。 

#0232 

#0233          if ��pHint ��= NULL�� 

#0234          �� 

#0235                  if ��pHint´〃IsKindOf��RUNTIME_CLASS��CStroke������ 

#0236                  �� 

#0237                          // The hint is that a stroke as been added ��or changed��。 

#0238                          // So�察�invalidate its rectangle。 

#0239                          CStroke* pStroke = ��CStroke*��pHint�察�

#0240                          CClientDC dc��this���察�

#0241                          OnPrepareDC��&dc���察�

#0242                          CRect rectInvalid = pStroke´〃GetBoundingRect�┌��察�

#0243                          dc。LPtoDP��&rectInvalid���察�

#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  頼屁圻兵�a 



#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�┌� 

卦指朕村 貧匯匈 和匯匈 指欺競何 壘��9�� 家��10��
酔楯荷恬: 梓囚徒貧圭�鮗� ○ 賜 ★ 辛酔堀貧和鍬匈 梓囚徒貧議 Enter 囚辛指欺云慕朕村匈 梓囚徒貧圭�鮗� ● 辛指欺云匈競何!
梁椣戻幣�� 梁心弌傍議揖扮窟燕得胎��傍竃徭失議心隈才凪万弌誌育断蛍�輌臆惨軼僑〃�燕慕得珊辛參資誼持蛍才将刮襲潜��範寔亟圻幹慕得 瓜寡追葎娼得辛參資誼寄楚署衛、持蛍才将刮襲潜填��