COpenGL::OnBeginPrinting![]()
bool OnBeginPrinting( HDC hPrintingContext, HDC hPrinterContext, float Scale = OBP_USE_RESIZE_MODE );
Parameters
| hPrintingContext | HDC of the device where we are going to print. This can be either device context handle of the screen window for print preview, or device context handle of printer. | ||
| hPrinterContext | HDC of the printer | ||
| Scale | Scale of the printed image. It can be either actual scale, or one of the following values. The scale has the same meaning as in SetScale method | ||
| |||
| |||
|
Return Values
true if success. false in case of error. Possible cause of error is wrong parameter, out of memory, or that OpenGL context compatible with printing device context cannot be created.
Remarks
The OnBeginPrinting method prepares the printing context for printing on full printer’s paper area. The scheme of using the OnBeginPrinting method is the same as using OnBeginPrinting method of MFC’s CView class. The OnBeginPrinting method must be called before calling COpenGL::OnPrint. After printing is done, the OnEndPrinting method must be called.
When using with MFC, call this method in your CView-class-overridden-OnBeginPrinting method.
This method is available since ClassGL version 3.5
Example
BOOL COpenGLView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void COpenGLView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
// initialize the "print drawing done" flag
m_PrintDrawingDone = false;
// pass this call to the COpenGL class
m_OpenGL.OnBeginPrinting( pDC->GetSafeHdc(), pInfo->m_pPD->m_pd.hDC );
// set rendering context attributes for printing
SetupOpenGLContextForPrinting();
}
void COpenGLView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// check whether we need to render the "print bitmap"
if ( ! m_PrintDrawingDone )
{
// draw the scene
OnDraw( pDC );
// set the "print drawing done" flag
m_PrintDrawingDone = true;
}
// pass this call to the COpenGL class
m_OpenGL.OnPrint( pDC->GetSafeHdc(), true );
}
void COpenGLView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// pass this call to the COpenGL class
m_OpenGL.OnEndPrinting();
}
void COpenGLView::SetupOpenGLContextForPrinting( void )
{
////////////////////////////////////////////////
// apply static settings as in ::OnCreate method
// set default interaction mode
….
}
See Also
OnEndPrinting, OnPrint, SetMaxPrintResolution, GetMaxPrintResolution
![]()
| © 2001 Solid Graphics, All rights reserved. |
| To view this site, we require use of either Netscape Navigator 4.0 or higher or Internet Explorer 4.0 or higher. |