⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book_text10.htm

📁 深入编程内幕vc++ 非常适合处学者学习
💻 HTM
📖 第 1 页 / 共 5 页
字号:
            style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">来完成的。做此设置后,应用框架便不会再调用</SPAN><SPAN 
            lang=EN-US 
            style="FONT-SIZE: 10.5pt; mso-bidi-font-size: 10.0pt">OnPrint,</SPAN><SPAN 
            style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">从而结束打印工作。</SPAN><SPAN 
            lang=EN-US style="FONT-SIZE: 10.5pt; mso-bidi-font-size: 10.0pt"><BR 
            style="mso-special-character: line-break"><BR 
            style="mso-special-character: line-break"><O:P></O:P></SPAN></P>
            <H3 style="mso-line-height-alt: 1.3pt"><A name=_Toc419881647><SPAN 
            lang=EN-US style="mso-bookmark: _Toc419740465">5.3 </SPAN></A><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: Times New Roman; mso-bookmark: _Toc419740465; mso-ascii-font-family: Times New Roman">打印工作的开始和结束</SPAN></H3>
            <P class=MsoNormalIndent style="mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">前面我们讨论了每一页打印的准备工作,在每一次打印任务之前和之后,应用框架也允许我们进行一些设置工作。在每次打印工作开始时,应用程序会跳出一个打印对话框,如图</SPAN><SPAN 
            lang=EN-US>3.13</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">。</SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">而应用框架在跳出这个对话框之前,会调用</SPAN><SPAN 
            lang=EN-US>OnPreparePrinting(CPrintInfo *pinfo),</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">我们可以通过调用</SPAN><SPAN 
            lang=EN-US>pinfo </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">的</SPAN><SPAN 
            lang=EN-US>SetMaxPage</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">和</SPAN><SPAN 
            lang=EN-US>SetMinPage </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">来设置出现在对话框中的最大最小页。</SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 20pt; mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">当关闭这个对话框之后,</SPAN><SPAN 
            lang=EN-US>OnBeginPrinting </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">会被调用。</SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 20pt; mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">当打印工作结束后,</SPAN><SPAN 
            lang=EN-US>OnEndPrinting</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">会被调用。</SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 175pt; mso-line-height-alt: 1.3pt"><!--[if gte vml 1]><O:WRAPBLOCK><V:SHAPETYPE 
            id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" 
            o:preferrelative="t" o:spt="75" coordsize="21600,21600"><V:STROKE 
            joinstyle="miter" /><V:FORMULAS><V:F 
            eqn="if lineDrawn pixelLineWidth 0" /><V:F eqn="sum @0 1 0" /><V:F 
            eqn="sum 0 0 @1" /><V:F eqn="prod @2 1 2" /><V:F 
            eqn="prod @3 21600 pixelWidth" /><V:F 
            eqn="prod @3 21600 pixelHeight" /><V:F eqn="sum @0 0 1" /><V:F 
            eqn="prod @6 1 2" /><V:F eqn="prod @7 21600 pixelWidth" /><V:F 
            eqn="sum @8 21600 0" /><V:F eqn="prod @7 21600 pixelHeight" /><V:F 
            eqn="sum @10 21600 0" /></V:FORMULAS><V:PATH o:connecttype="rect" 
            gradientshapeok="t" o:extrusionok="f" /><O:LOCK aspectratio="t" 
            v:ext="edit" /></V:SHAPETYPE><V:SHAPE id=_x0000_s1026 
            style="MARGIN-TOP: 13.55pt; Z-INDEX: 1; LEFT: 0px; MARGIN-LEFT: 90pt; WIDTH: 217pt; POSITION: absolute; HEIGHT: 156.4pt; TEXT-ALIGN: left; mso-position-horizontal-relative: text; mso-position-vertical-relative: text" 
            o:allowincell="f" type="#_x0000_t75"><V:IMAGEDATA o:title="" 
            src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msoclip1/01/clip_image001.png" 
            /><W:WRAP type="topAndBottom" /></V:SHAPE><![endif]--><SPAN 
            style="mso-ignore: vglayout">
            <TABLE cellSpacing=0 cellPadding=0>
              <TBODY>
              <TR>
                <TD width=120 height=0></TD></TR>
              <TR>
                <TD></TD>
                <TD><IMG height=209 src="book_text10.files/book_t1.jpg" 
                  width=289 v:shapes="_x0000_s1026"></TD></TR></TBODY></TABLE></SPAN><!--[if gte vml 1]></O:WRAPBLOCK><![endif]--><BR 
            style="mso-ignore: vglayout" clear=all><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">图</SPAN><SPAN 
            lang=EN-US>3.13</SPAN> 
            <H3 style="mso-line-height-alt: 1.3pt"><A name=_Toc419881648><SPAN 
            lang=EN-US style="mso-bookmark: _Toc419740466">5.4 </SPAN></A><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: Times New Roman; mso-bookmark: _Toc419740466; mso-ascii-font-family: Times New Roman">打印程序实例</SPAN></H3>
            <P class=MsoNormalIndent style="mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">在这里,我们制作了一个包含了打印功能的例子。它从一个学生信息数据库中抽取所有的记录,然后显示在一个</SPAN><SPAN 
            lang=EN-US>CScrollView</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中,当用户要将它们打印出来时,程序按每页打印五条记录将这些记录打印出来。这个例子中用到了</SPAN><SPAN 
            lang=EN-US>DAO </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">来访问数据库,在本书的前面章节中已介绍过,读者可以先复习一下,在本章我们不会详细解释相应的语句。</SPAN></P>
            <P class=MsoNormalIndent style="mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">在这个例子中,我们先利用</SPAN><SPAN 
            lang=EN-US>APPWizard</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">生成一个应用程序框架。注意在生成的第六步中将</SPAN><SPAN 
            lang=EN-US>CPrintView </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">的基类从</SPAN><SPAN 
            lang=EN-US>CView<SPAN style="mso-spacerun: yes">&nbsp; 
            </SPAN></SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">改成</SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 170pt; mso-line-height-alt: 1.3pt"><!--[if gte vml 1]><O:WRAPBLOCK><V:SHAPE 
            id=_x0000_s1027 
            style="MARGIN-TOP: 2.05pt; Z-INDEX: 2; LEFT: 0px; MARGIN-LEFT: 44.65pt; WIDTH: 285.35pt; POSITION: absolute; HEIGHT: 217.8pt; TEXT-ALIGN: left; mso-position-horizontal-relative: text; mso-position-vertical-relative: text" 
            o:allowincell="f" type="#_x0000_t75"><V:IMAGEDATA o:title="" 
            src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msoclip1/01/clip_image003.png" 
            /><W:WRAP type="topAndBottom" /></V:SHAPE><![endif]--><SPAN 
            style="mso-ignore: vglayout">
            <TABLE cellSpacing=0 cellPadding=0>
              <TBODY>
              <TR>
                <TD width=60 height=0></TD></TR>
              <TR>
                <TD></TD>
                <TD><IMG height=290 src="book_text10.files/book_t2.jpg" 
                  width=380 v:shapes="_x0000_s1027"></TD></TR></TBODY></TABLE></SPAN><!--[if gte vml 1]></O:WRAPBLOCK><![endif]--><BR 
            style="mso-ignore: vglayout" clear=all><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">图</SPAN><SPAN 
            lang=EN-US>3.14</SPAN> 
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US>CScrollView,</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">如图</SPAN><SPAN 
            lang=EN-US>3.14</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">所示。</SPAN></P>
            <P class=MsoNormalIndent style="mso-line-height-alt: 1.3pt"><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">在这个例子中,我们就分开考虑打印和显示输出,即在</SPAN><SPAN 
            lang=EN-US>OnPrint</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中考虑打印,在</SPAN><SPAN 
            lang=EN-US>OnPaint </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中考虑显示输出。而在</SPAN><SPAN 
            lang=EN-US>OnDraw </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">不做任何工作。</SPAN></P>
            <P class=MsoNormalIndent style="mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            </SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">在</SPAN><SPAN 
            lang=EN-US>CPrintView</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">中,我们添加一个虚函数:</SPAN><SPAN 
            lang=EN-US>OnPreparePrinting,</SPAN><SPAN 
            style="FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-ascii-font-family: 'Times New Roman'">其代码如下:</SPAN><SPAN 
            lang=EN-US><BR></SPAN><SPAN lang=EN-US 
            style="BACKGROUND: #d9d9d9; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'; mso-shading: white; mso-pattern: gray-15 black">BOOL 
            CPrintView::OnPreparePrinting(CPrintInfo* pInfo)<O:P> 
            </O:P></SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US 
            style="BACKGROUND: #d9d9d9; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'; mso-shading: white; mso-pattern: gray-15 black">{<O:P> 
            </O:P></SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US 
            style="BACKGROUND: #d9d9d9; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'; mso-shading: white; mso-pattern: gray-15 black"><SPAN 
            style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>// default 
            preparation<O:P> </O:P></SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US 
            style="BACKGROUND: #d9d9d9; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'; mso-shading: white; mso-pattern: gray-15 black"><SPAN 
            style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; 
            </SPAN>pInfo_&gt;SetMaxPage((Recnumber+4)/5);<O:P> </O:P></SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 
            lang=EN-US 
            style="BACKGROUND: #d9d9d9; FONT-FAMILY: 'Courier New'; mso-bidi-font-family: 'Times New Roman'; mso-shading: white; mso-pattern: gray-15 black"><SPAN 
            style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>return 
            DoPreparePrinting(pInfo);<O:P> </O:P></SPAN></P>
            <P class=MsoNormalIndent 
            style="TEXT-INDENT: 0cm; mso-line-height-alt: 1.3pt"><SPAN 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -