Print in an SDI application
-
Hi, In my MFC SDI application, there is a "File | Print" automatically created from the wizard which prints my CHtmlView successfully. Now I would like to issue this command *manually* from my view. Which method do I need to call? Thank you!
Is
ShellExecute
(with verb "print") helpful ? Regards, Paresh. -
Is
ShellExecute
(with verb "print") helpful ? Regards, Paresh. -
Hi, In my MFC SDI application, there is a "File | Print" automatically created from the wizard which prints my CHtmlView successfully. Now I would like to issue this command *manually* from my view. Which method do I need to call? Thank you!
Use this code snippet to print your view from anywhere. The core idea is to call
CView::OnCmdMsg()
by passingID_FILE_PRINT
orID_FILE_PRINT_DIRECT
.// 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 );
}Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
-
Use this code snippet to print your view from anywhere. The core idea is to call
CView::OnCmdMsg()
by passingID_FILE_PRINT
orID_FILE_PRINT_DIRECT
.// 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 );
}Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.