亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apc.htm

?? 好的教程Vc++21 天
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<P>As I mentioned earlier, the code in Listing C.4 works fine, but there is a betterway to allocate the resources needed. Currently every time a page is printed, OnPrint()is called to draw the page, and all the resources are created from scratch. Thatprobably won't slow things down too much for this simple output, but in a large,complex report you might want to set up a number of resources and other calculationsjust once at the start of the report. Then you can print a number of pages and cleanup the resources at the end of the report.</P><P>The OnBeginPrinting()virtual function is an ideal place to do this initialization,and its sister function, OnEndPrinting(), is the place to clean up these resources.OnBeginPrinting() is called after OnPreparePrinting() and is the first place wherea printer device context is passed in. This device context is the one that is usedduring the printing process, so you can set up all the GDI objects and printer pagecoordinates at this point. The default code supplied automatically by the ClassWizardjust gives you an empty function:</P><P><PRE>void CPrintItView::OnBeginPrinting(CDC* /*pDC*/, &Acirc; CPrintInfo* /*pInfo*/){    // TODO: add extra initialization before printing}</PRE><P>Take a close look at that function definition. Notice the parameters are actuallycommented out to the compiler, throwing warning messages about unused parameterswhen you compile. You'll have to remember to uncomment these parameters before youstart using them.</P><P>You can now add the GDI object creation calls to this function to avoid doingit on every page:</P><P><PRE>m_fnTimes.CreatePointFont(720,&quot;Times New Roman&quot;,pDC);m_brHatch.CreateHatchBrush(HS_CROSS,RGB(64,64,64));</PRE><P>Notice that the fnTimes and brHatch objects have been prefixed by an m_; thisis a naming convention to indicate that the objects have class scope (are embeddedin the class) rather than local scope (are embedded in the function). Because you'llneed to access these GDI objects in OnPrint(), you can add them to the class declaration.You can do this by adding the font and brush objects to the class declaration likethis:</P><P><PRE>protected:    CFont     m_fnTimes;    CBrush    m_brHatch;</PRE><P>You can add these either by double-clicking the CPrintItView class in the ClassViewand adding them directly or by using the Add Member Variable dialog box.</P><P>Also notice that the hatched brush is created with the CreateHatchBrush() functionrather than with the constructor. This is because the brush will exist as long asthe view does, but you must call DeleteObject() in the OnBeginPrinting() functionso that the underlying GDI resource is freed between prints. You can add the codeto delete both the font and brush GDI objects in OnEndPrinting(), as shown in theselines:</P><P><PRE>m_fnTimes.DeleteObject();m_brHatch.DeleteObject();</PRE><P>All that remains is to remove the local GDI objects from the OnPrint() functionitself and replace their references with the member variable versions. You can dothis by replacing the CFont fnTimes and CBrush brHatch local variables and theircreation functions and just selecting the precreated font and brush:</P><P><PRE>CFont* pOldFont = (CFont*)pDC-&gt;SelectObject(&amp;m_fnTimes);CBrush* pOldBrush = (CBrush*)pDC-&gt;SelectObject(&amp;m_brHatch);</PRE><P>If you were to build and run the application after making these changes, you'dprobably notice no difference. Functionally it's the same, but the print and previewshould be a little faster. If you had a large, complex 100-page report using lotsof GDI resources, you'd definitely find this technique useful in speeding up theprinting.</P><BLOCKQUOTE>	<P><HR><B>USING COORDINATES FROM </B>OnBeginPrinting()</P>	<P>You might be tempted to also store the coordinates from OnBeginPrinting(). This	won't work because CPrintInfo's m_rectDraw member hasn't been initialized by that	stage and random coordinates will be used.<HR></BLOCKQUOTE><H3><A NAME="Heading12"></A>Customizing Device Context Preparation</H3><P>Before both OnDraw() and OnPrint() are called, the OnPrepareDC() virtual functionis called and can be overridden in your view class to perform any device contextmodifications that might be common to both OnDraw() and OnPrint(). You might wantto set mapping modes or set certain common draw modes to the device context for bothonscreen and printing modes. The override isn't supplied by the AppWizard, but caneasily be added from the Add Virtual Function dialog box. One thing common to bothOnDraw() and OnPrint() in the example is the SetTextAlign() device context function.You could add this to an OnPrepareDC() function like this:</P><P><PRE>void CPrintItView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo){    pDC-&gt;SetTextAlign(TA_CENTER+TA_BASELINE);}</PRE><P>There might be times, especially when preparing WYSIWYG printouts, that it isadvantageous to set mapping modes and window extents in a common function beforethe draw or print function is called. OnPrepareDC() is the place to put any devicecontext-specific initialization code.</P><P><H3><A NAME="Heading13"></A>Aborting the Print Job</H3><P>Another use of OnPrepareDC() is to call printer escapes or other print document-specificfunctions. If you had a particularly long report, you might want to give the userthe option of terminating the printing process and aborting the print. The AbortDoc()device context function aborts the printing document for a printer device context.You can try this by adding the following lines to OnPrepareDC() and aborting thedocument after three pages:</P><P><PRE>if (pDC-&gt;IsPrinting())    if (pInfo-&gt;m_nCurPage==3) pDC-&gt;AbortDoc();</PRE><H2><A NAME="Heading14"></A>Direct Printing Without the Framework</H2><P>So far in this chapter, I've shown you the SDI and MDI framework support for printing.This support melds nicely into the Document/View architecture, but there are timeswhen you just want quick and easy access to a printer or don't have the frameworkavailable--in a dialog-based application, for example.</P><P>The framework support hides lower-level printing support that is the bedrock forall the printing operations. This section explains how this support works and showsit in use in a dialog box-based application example.</P><P><H3><A NAME="Heading15"></A>Invoking the Print Dialog Box Directly</H3><P>You saw in the earlier section &quot;Using the Print Dialog Box&quot; how theCPrintDialog class provides a wrapper for the common PRINTDLG dialog and how thiswas called from CView::DoPreparePrinting().</P><P>The same dialog box and class can be used directly to set up the destination printerand its default settings just like you'd use a normal modal dialog box. You can usethe same access functions to set the page numbers and copy defaults as you used frominside the framework's DoPreparePrinting() function.</P><P>Listing C.7 shows this dialog box being used directly to configure the printerfor dialog box-based printing and then prints a small document from the defaultsset by the dialog box.</P><P>The direct printing mechanism works via the StartDoc() and EndDoc() functionsshown in this listing and is explained in the next section.</P><P>You can use the AppWizard to create a dialog box-based application named DlgPrintand create an OnOK() handler with the ClassWizard to implement the printing code,as shown in Listing C.7.</P><P><H4>LISITNG C.7.&nbsp;&nbsp;LST23_7.CPP--IMPLEMENTING A DIRECT DOCUMENT PRINT INOnOK OF A DIALOG BOX-BASED APPLICATION.</H4><PRE>1:  void CDlgPrintDlg::OnOK()2:  {3:      // TODO: Add extra validation here4:5:      // ** Construct a CPrintDialog object6:      CPrintDialog dlgPrint(FALSE,PD_ALLPAGES,this);7:8:      if (dlgPrint.DoModal()==IDOK)9:      {10:          // ** Attach the printer DC from the dialog11:          // ** to a CDC object12:          CDC dcPrint;13:          dcPrint.Attach(dlgPrint.GetPrinterDC());14:15:          // ** Create and fill a DOCINFO structure16:          DOCINFO myPrintJob;17:          myPrintJob.cbSize = sizeof(myPrintJob);18:          myPrintJob.lpszDocName = &quot;MyPrintJob&quot;;19:          myPrintJob.lpszOutput = NULL;20:          myPrintJob.lpszDatatype = NULL;21:          myPrintJob.fwType = NULL;22:23:          // ** Start the printing document24:          if (dcPrint.StartDoc(&amp;myPrintJob)&gt;=0)25:          {26:              // ** Start a page27:              dcPrint.StartPage();28:29:              // ** Start drawing30:              dcPrint.TextOut(0,0,&quot;My Small Print Job&quot;);31:32:              // ** Throw the page33:              dcPrint.EndPage();34:35:              // ** Close the document36:              dcPrint.EndDoc();37:          }38:39:          // ** Delete the printer device context40:          dcPrint.DeleteDC();41:      }42:43:      // ** Carry on with the standard OnOK44:      CDialog::OnOK();45:  }</PRE><P>Listing C.7 declares a CPrintDialog object dlgPrint at line 6 that takes threeparameters in its constructor. The first parameter is a flag that can be set as TRUEto display the Print Setup dialog box, or FALSE to display the Print dialog box.The second parameter is a set of combinable flags that customize the settings ofthe dialog box (too numerous to cover here). The third parameter is a pointer tothe parent window; in this case the C++ this pointer indicates that the dialog boxis the parent.</P><P>On line 8, dlgPrint.DoModal()is called to display this dialog box. If the userclicks OK, the print begins; otherwise, the block is skipped.</P><P>When the user has clicked OK in the Print dialog box, a device context for theprinter is created and attached to a CDC object in line 13 to make it easier to use.You must remember to delete the device context itself, as shown in line 40.</P><P>You can add the listing lines and handler, build and run it, and click OK of thedialog box application to run the new code.</P><P><H3><A NAME="Heading16"></A>Using StartDoc() and EndDoc()</H3><P>The CDC device context has many printer-specific functions. To start a new print,Windows must create a spool document to store the print job and submit it to theprinter when it is complete. The StartDoc() function tells Windows to start spooling,and the EndDoc() function tells it that the document is complete and can be sentto the printer. You saw the AbortDoc() function earlier that will abort the printand cancel the print job rather than send to the printer.</P><P>Listing C.7 calls the StartDoc() member of the printer device context object dcPrintat line 24, passing a pointer to a DOCINFO structure. This structure holds the detailsof the print job. The only detail you must specify is a name for the spool document,which is assigned at line 18. Notice that it has an unusual cbSize member that holdsthe size of the structure. This is assigned the value from sizeof(myPrintJob) atline 17. You see this sort of strange action going on a lot at the Win32 API levelbecause DOCINFO is an old C-style structure; the cbSize is used because there area few different forms of DOCINFO and the only way to tell them apart is the size.</P><P>When StartDoc() is called, it will try to start the print job and return a positivevalue if it succeeds. There are many reasons why it might fail, such as low diskspace or memory, or a corrupt printer driver, so it's a good idea to carry on withthe print only after checking the return code.</P><P>After the document is printed, you should call EndDoc() as shown on line 36 tostart printing the document.</P><BLOCKQUOTE>	<P><HR><B>WATCHING THE WINDOWS SPOOLER</B></P>	<P>You can watch the print document as it builds up by placing a breakpoint in the	OnPrint() function or after a StartDoc() function and opening your printer status	icon from the Printers group available from the main Windows Start menu under the	Settings option.<HR></BLOCKQUOTE><H3><A NAME="Heading17"></A>Using StartPage() and EndPage()</H3><P>Another pair of printer device context functions are StartPage() and EndPage().The StartPage() function is used to initialize the device context ready for printinga new page. This will reset some of the device context settings such as the currentgraphics cursor position and set the document spooling information for starting anew page.</P><P>Typically, you'd call StartPage(), do some drawing in the device context for thedetails to be printed on that page, and call EndPage() to write the page away tothe spool file to add it to the print document.</P><P>In Listing C.7, StartPage() is called on line 27, followed by a solitary TextOut()function to draw something on the printer page, followed by a call to EndPage() online 33.</P><P>When EndPage() is called, the special printer codes for throwing a Form Feed aresent to the spooler and the spool document registers another print page. You canrepeat this StartPage() and EndPage() sequence for all the document pages beforecalling EndDoc() to complete the printing process. You can use the printer devicecontext for drawing in just the same way as the OnPrint() was used in the SDI applicationin between the StartPage() and EndPage() calls. The same functions were called inthe SDI framework, but the framework hides it from you, only calling your OnPrint()between start and end page calls.</P><H1></H1><CENTER><P><HR><A HREF="../apb/apb.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apd/apd.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR><BR></P><P>&copy; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合一区二区| 欧美日韩一区二区不卡| 亚洲三级电影网站| 在线亚洲+欧美+日本专区| 亚洲一区二区在线免费看| 欧美日韩一区三区四区| 伦理电影国产精品| 久久久国产午夜精品| 欧美探花视频资源| 久久成人免费日本黄色| 亚洲欧洲在线观看av| 欧美久久久久免费| 国产成人午夜99999| 午夜精品在线看| 国产夜色精品一区二区av| 欧美精品tushy高清| 成人av小说网| 男女激情视频一区| 亚洲欧洲精品一区二区三区| 日韩一区二区高清| 在线视频一区二区三区| 国产成人精品影视| 麻豆91精品视频| 亚洲综合小说图片| 亚洲日本va午夜在线影院| 久久久久久9999| 欧美一区二区三区视频在线观看| 色婷婷av一区二区三区大白胸| 99久久久精品免费观看国产蜜| 免费在线视频一区| 亚洲三级在线免费| 91麻豆精品国产91久久久久久久久 | 精品久久久久一区二区国产| 大陆成人av片| 日韩av一区二| 亚洲精选一二三| 精品电影一区二区| 欧美日韩国产免费| 国产福利一区二区三区| 日韩vs国产vs欧美| 中文字幕免费不卡在线| 欧美一区二区三区成人| 欧美亚洲日本国产| 懂色av噜噜一区二区三区av| 日韩高清不卡一区二区三区| 亚洲v日本v欧美v久久精品| 中文字幕一区二区三区视频| 精品久久久久久最新网址| 91精品国产欧美一区二区18| 欧美日韩国产高清一区二区三区| 成人网男人的天堂| 91福利国产成人精品照片| 99国产精品国产精品久久| 国产.欧美.日韩| 韩国成人精品a∨在线观看| 99久久综合色| 成人午夜视频福利| 97国产一区二区| 色婷婷av一区二区| 欧美色男人天堂| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲bt欧美bt精品| 天堂久久一区二区三区| 日韩**一区毛片| 亚洲aⅴ怡春院| 精一区二区三区| 国产一区二区中文字幕| 国产成人高清视频| 日本韩国欧美在线| 欧美人与禽zozo性伦| 久久嫩草精品久久久精品一| 国产农村妇女精品| 亚洲欧美另类图片小说| 亚洲女性喷水在线观看一区| 亚洲国产日日夜夜| 蜜臀91精品一区二区三区| 国产91精品一区二区麻豆网站 | 91网站视频在线观看| 色综合久久综合网| 欧美一级电影网站| 国产调教视频一区| 亚洲综合久久久| av日韩在线网站| 欧美一级免费大片| 亚洲欧美日韩在线不卡| 日本女优在线视频一区二区| 日韩高清欧美激情| 成人午夜视频在线观看| 337p亚洲精品色噜噜噜| 中文字幕欧美国产| 久久精品国产99久久6| 色婷婷亚洲婷婷| 国产精品无码永久免费888| 美女精品一区二区| 色偷偷久久一区二区三区| 精品国产一区二区三区av性色| 亚洲精品成人在线| 国产一区在线观看麻豆| 欧美丰满少妇xxxbbb| 一区二区在线观看免费视频播放 | 91视频.com| 久久蜜桃av一区二区天堂 | 亚洲国产精品一区二区尤物区| 美女视频黄a大片欧美| 欧美日韩三级在线| 欧美韩国日本一区| 成人午夜私人影院| 日韩一区二区三区四区五区六区| 亚洲精品国久久99热| 国产精品主播直播| 精品对白一区国产伦| 久久精品国产99国产| 欧美巨大另类极品videosbest | 欧美性做爰猛烈叫床潮| 国产精品国产精品国产专区不片| 青青草国产精品亚洲专区无| 欧美挠脚心视频网站| 日精品一区二区三区| 欧美日韩激情一区二区| 一区二区欧美精品| 欧洲av一区二区嗯嗯嗯啊| 亚洲欧美在线视频观看| 国产美女在线观看一区| 国产精品欧美久久久久一区二区| 成人黄色免费短视频| 亚洲婷婷综合色高清在线| 一本大道综合伊人精品热热| 一区二区三区中文免费| 91麻豆精品91久久久久同性| 日日欢夜夜爽一区| 精品国内二区三区| 成人精品鲁一区一区二区| 亚洲国产裸拍裸体视频在线观看乱了| 91视频.com| 日韩黄色在线观看| 国产香蕉久久精品综合网| 成人免费福利片| 亚洲综合一二三区| 久久久精品人体av艺术| 日本韩国欧美一区| 亚洲va国产天堂va久久en| 国产亚洲欧美日韩俺去了| 欧美综合欧美视频| 麻豆中文一区二区| 综合电影一区二区三区 | 日韩精彩视频在线观看| 久久亚洲一级片| 日本韩国精品一区二区在线观看| 天天爽夜夜爽夜夜爽精品视频| 久久久久久免费毛片精品| 欧洲日韩一区二区三区| 亚洲午夜一区二区| 久久亚区不卡日本| 欧美三级乱人伦电影| 成人黄动漫网站免费app| 蜜臀久久99精品久久久久宅男| 亚洲人成网站精品片在线观看| 久久亚洲捆绑美女| jiyouzz国产精品久久| 黑人巨大精品欧美一区| 日产欧产美韩系列久久99| 午夜精品久久久久久久久| 国产视频亚洲色图| 91麻豆精品国产自产在线| 成人一区二区视频| 久久精品国产亚洲aⅴ | 亚洲成人av一区二区三区| 久久免费国产精品| 精品国产免费视频| 久久这里都是精品| 麻豆精品一区二区av白丝在线| 欧美军同video69gay| 无码av中文一区二区三区桃花岛| 日本韩国一区二区三区视频| 亚洲综合在线观看视频| 欧美精品高清视频| 极品尤物av久久免费看| 中文字幕一区在线观看视频| 欧美日韩亚洲另类| 韩国成人福利片在线播放| 国产精品高清亚洲| 91精品国产综合久久福利软件| 国产一区二区久久| 亚洲国产精品久久一线不卡| 精品久久99ma| 欧美色综合影院| 国产精品99久久久久| 丝袜美腿亚洲色图| 国产精品福利影院| 精品国产乱码久久久久久久久| 99国产精品久久久久久久久久| 视频在线观看一区| 亚洲精品国产无天堂网2021 | 精品国产青草久久久久福利| 色噜噜狠狠成人中文综合| 国产精品 欧美精品| 国产综合久久久久久久久久久久| 亚洲综合丝袜美腿| 亚洲人成精品久久久久| 精品久久久久一区二区国产|