How to Print the CView directly to Printer?
You have to call CView::OnCmdMsg() by passing ID_FILE_PRINT or ID_FILE_PRINT_DIRECT. If ID_FILE_PRINT is passed, the printer dialog will be shown and for ID_FILE_PRINT_DIRECT, the print will be taken directly with default printer parameters. Have a look at the code snippet.
// Get the active view.
CFrameWnd* pFrameWnd = (CFrameWnd*)AfxGetApp()->GetMainWnd();
CView* pView = pFrameWnd->GetActiveView();
if( pView != NULL )
{
// Send Print message.
// If you want to print directly, then change ID_FILE_PRINT
// to ID_FILE_PRINT_DIRECT.
pView->OnCmdMsg( ID_FILE_PRINT, 0, 0, 0 );
}

0 comments:
Post a Comment