I haven't written a technical article for a long time. This time because I have received a school, there is no way. I will force me to continue to learn VC . Now I have already hard to learn, although I know this thing is hard, but I believe I have returned. Victory, and, there are so many friends help, I believe I will study back.
This teacher lets us go back to prepare for the system to change the previous enrollment system, mainly to add two functions: 1, print and printing the pre-cable function 2, digital camera function
For some of the high-class intentions in the MFC in the first function, and check some information, then you will see it yourself, think it is something set to some parameters, just need more careful. Yesterday, I saw the following related content, the process seems to be: onfileprint () -> cview :: onprepareprinting () -> cview :: onbeginprinting () -> cdc :: onstartdoc () -> cdc :: onStartPage () -> CView :: OnPrint () -> onStoppage () -> CDC :: OnStOPDoc-> CView :: OnendPrint (), where in onstoppage, if you need to print the article is multi-page, it is automatically returned to OnStartPage, The new page prints, all the time to print, you can complete the printed function. However, in the message, the drop-down menu is enabled by ON_FILE_PRINT, where some of its own uses and functions can also be added here, and some of the user-defined features. And the function of printing previews is that it is set to set a parameter. I remember that I don't have very much, it looks very simple. Hey, I said so much may have been confused, or look at others!
Source: Source Sky Address: http://www.codesky.net/Article/List.asp? Id = 3232 If you have tried encoded in a C-based SDK program to generate printouts, you will like MFC print support. Although it is not a thorough solution, it really exceeds SDK coding. Since printing support is derived from CVIEW, the document / view structure is necessary to pay attention to cumbersome handle. A device-independent device requires a description table as a logical canvas for painting. As shown in the display device description table, the printer must have a print device descriptor. When using a graphic function, the MFC uses the same code on the display device description table and the printer device description table drawing. This two weight is achieved by a CView :: overdraw () method. The device description of the CView :: OnDraw () can come from anywhere representing two different devices, which arranged for MFC-independent printing and print previews provide a number of means. Printing Circuit CView :: OnfilePrint () MFC uses 8 main methods as its "printing printed", each step of the printing process contains calls to a CView method, see the following table CVIEW Print method Method ONFILEPRINT () Run Print The main print method of the loop overprepareprinting () calls doprepareprinting () to display the Print dialog DOPREPAREPRINTING () Display Print dialog online OnBeginPrinting () allocates the position onPreparedc () on OnPrepAREDC () before OnPrint () by MFC transfer. As the image mode, this method should be located at the setup DC attribute to call OnDraw () onDraw () to reproduce the document data in printer DC OnendPrinting () by the printer of printing or printing preview, uses MFC, use The method releases the GDI resource for a particularly allocated specific printer such that the MFC can respond to the print command, which must define a message image entry, which causes the predefined MFC value ID_File_print to control the cView :: onfileprint () method of the control print process. . This method calls other CVIEW help methods to automate a large number of printing processes. You can call CView :: OnfilePrint () directly with code. Or, the MFC calls it to respond to any command message with an on_file_print value (such as the print command on the menu). Because ONFilePrint () is a protected class member, this must reside in a message image of the view class, as described below: Begin_MESSAGE_MAP (CMYVIEW, CVIEW) ... // Required for Printingon_Command (ID_FILE_PRINT, CVIEW: ONFILEPRINT) END_MESSAGE_MAP () Preparing to print for printing and print previews for MFC applications, there is only one way you must redesign: cview :: onprepareprintinf (), the virtual method is called by MFC before printing or previewing, whose prototype is as follows: Virtual Bool OnPrepareprinting (CPrintInfo * PINFO); PINFO parameter is a pointer to the CPRINFO object that contains the current print job information. Note: If the print job is canceled by the user in the result print dialog box, the cview :: onprepareprinting () method calls the cview :: doprepareprinting () method and returns zero.
CPrintinfo structure ------------------------------------------ strut cprintinfo // printing information structure {CPrintInfo (); ~ CPrintInfo (); CPrintDialog * m_pPD; // pointer to print dialogBOOL m_bPreview; // TRUE if in preview modeBOOL m_bDirect; // TRUE if bypassing Print DialogBOOL m_bContinuePrinting; // set to FALSE to end printingUINT m_nCurPage; // Current pagesUINT m_nNumPreviewPages; // Desired number of preview pagesCString m_strPageDesc; // Format string for page number displayLPVOID m_lpUserData; // pointer to user created structCRect m_rectDraw; // rectangle defining usable page areavoid setMinPage (UINT nMinPage); void SetMaxPage (uint getMAXPage () const; uint getMaxpage () const; uint getfromPage () const; uint gettoppage () const; uint gettoppage () const;} CPRINTINFO class data member data member description M_ppd points to the pointer to the CPRINT Dialog object as the Print dialog M_BDirect indicates whether the document is printing, and its Bypass dialog m_bpreview indicates whether the document is previewing M_BContinuePrinting Indicates whether the MFC should be kept in the printed loop M_NCurpage Current page number m_nnnumpreviewPages Unce you want to display how many pages should be displayed Print preview window: 1 or 2 m_lpuserdata points to the pointer M_R of the application definition structure ECTDRAW Defines the rectangular box m_strpagedesc of the currently available page area on the printer DC M_StrPageDesc contains a format string of the page number display information CPrintInfo class method Description SetMinPage () Specifies the first page of the document (usually 1) setMaxPage () Specify the document Last page number getMinPage () Gets the first page of the document GetMaxPage () Get the latest page of the document GetFromPage () Get the first page of the first page to be printed Gettopage () Get the last page number of the Top Site PRINT dialog CView :: onprepareprinting () The default implementation of the method is as follows: BOOL CDOCVIEW2VIEW :: OnPreParePrinting (CprintInfo * Pinfo) {// default preparationReturn DopReprePRINTINTING (PINFO);} This default handler is only called CView :: DOPREPAREPRINTINTING () method, the latter automatically handles call, not Consider the PRING dialog. This dialog is called from a cView :: doprepareprinting () method that points to the CPRINTINFO object.
CView :: DOPREPAREPRINTING () method has the following prototype: BOOL DOPREPAREPRINTING (CPRINTINFO * PINFO); MFC uses a value of various CPRINTINFO class data using a value entered by the user in the Print box, then the Print dialog box as a CPRINFO object member (Pinfo- > m_ppd), create a print device description table as its HDC member, the method is as follows: if (Pinfo-> m_ppd-> m_pd.hdc == null) {// call createprinterdc if DC WAS NOT CREATED BY Aboveif (Pinfo-> m_ppd- > CREATEPRINTERDC () == NULL) Return False;} Tip: Set the CPRINTINFO class member to control the display value on the print dialog before calling CView :: DOPReparePrinting (). The appearance of the value you specify is in the corresponding dialog control. If the M_BPREVIEW member is false, only the Print dialog is displayed; the dialog does not appear in the print preview process. You can control the appearance of the M_BPREVIEW Member Value to control the appearance of the dialog box, and the PRINT dialog of the actual print job can be used. The print setting Description Table is created and the CPRINTINFO data in CView :: doprepareprinting () is initialized, and the method CView :: onprepareprinting () is exited. The next stop of the MFC print routine is a cview :: OnBeginPrinting () method. The primary task of starting print job cview :: OnBeginPrinting () method is to make legitimate print DCs are available to your application. Redesign the method to provide initialization based on the printer DC characteristics. The prototype of this method is represented as follows: Virtual Void OnBeginPrinting (CDC * PDC, CPrintInfo * PINFO); MFC calls the method when printing or printing preview jobs, the latter does not work in the default CVIEW implementation. By redesign the ONBEGINPRINT () path, you can allocate any GDI resources that may be needed during printing. If you assign GDI objects in OnBeginPrint (), for example, select a few brushes into the print DC, can be selected from the priority cView :: onprint () method, print actually performed inside it (via CView :: Ondraw) After returning from OnBeginPrint (), the onfileprint () method starts the master print loop, and each page of the document is initialized and (in length) is initially printed. Preparing the print device description table to call the onpreparedc () method to adjust the DC's characteristics before using any graphical method (ie, in the onDraw () method). The prototype of this method is as follows: Virtual Void OnPreParedc (CDC * PDC, CPrintInfo * PINFO = NULL); this method is typically redesigned to set some other features of the new image or DC. After the print job calls overpreparedc (), the MFC calls the cview :: onprint () method to print or preview each document page: Virtual Void Onprint (CDC * PDC, CPRINFO * PINFO); OnPrint () uses the M_NCurPage member of the CPrintInfo structure to determine Printing the current page, then OnPrint () calls onDraw () to draw the page on the printer DC. Each page of the document is called once onPrint () method. If you have multiple page documents that you need to redesign this overhead to implement page print logic.
This requires only the current page of OnDraw () by the operation window origin, so that each iterative view of the print loop will move a page, which allows you to print only the pleates such as header and footer. Here is a minimum redesigned onprint () method, which finally calls an onDraw () method with print DC as a parameter: void csomeview :: onprint (cdc * pdc, cprintinfo * pinfo) {onDraw (PDC); The document exceeds one page, the next iteration of the print cycle starts from OnPrint (). After the printing of the document is printed, the print loop ends (or the print preview end), the MFC call can redesign the cView :: OnendPrinting () method to release any GDI resource allocated in OnBeginPrinting (). The prototype of this method is as follows: Virtual Void OneendPrinting (CDC * PDC, CPrintInfo * PINFO); Note: If the printer image is different from the displayed image, the allocation and release of ONBEGINPRINTING () is usually used when the printer-specific GDI resource is required. GDI resources in the method. For the second question, I now only have a preliminary influence, knowing the approximate steps, but the detailed details have not been tried, check the following MSDN, found that if only one simple function is only, only two steps Can be completed, first connect the video device, then create a capture window to operate the content of the video device, use two functions, one is the CapCreateCaptureWindow () and CAPDriverConnect () functions, now I know these probably, but still I didn't have seriously read the relevant details, wait for me to read it again!
Hey! I hope that I can read this thing before I will go back, because I still have a bigger thing to do!