다음을 통해 공유


CView::OnBeginPrinting

Called by the framework at the beginning of a print or print preview job, after OnPreparePrinting has been called.

virtual void OnBeginPrinting(
   CDC* pDC,
   CPrintInfo* pInfo 
);

Parameters

  • pDC
    Points to the printer device context.

  • pInfo
    Points to a CPrintInfo structure that describes the current print job.

Remarks

The default implementation of this function does nothing. Override this function to allocate any GDI resources, such as pens or fonts, needed specifically for printing. Select the GDI objects into the device context from within the OnPrint member function for each page that uses them. If you are using the same view object to perform both screen display and printing, use separate variables for the GDI resources needed for each display; this allows you to update the screen during printing.

You can also use this function to perform initializations that depend on properties of the printer device context. For example, the number of pages needed to print the document may depend on settings that the user specified from the Print dialog box (such as page length). In such a situation, you cannot specify the document length in the OnPreparePrinting member function, where you would normally do so; you must wait until the printer device context has been created based on the dialog box settings. OnBeginPrinting is the first overridable function that gives you access to the CDC object representing the printer device context, so you can set the document length from this function. Note that if the document length is not specified by this time, a scroll bar is not displayed during print preview.

Requirements

Header: afxwin.h

See Also

Reference

CView Class

Hierarchy Chart

CView::OnEndPrinting

CView::OnPreparePrinting

CView::OnPrint

Other Resources

CView Members