Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Print in an SDI application

Print in an SDI application

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nobaq
    wrote on last edited by
    #1

    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!

    P J 2 Replies Last reply
    0
    • N nobaq

      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!

      P Offline
      P Offline
      Paresh Chitte
      wrote on last edited by
      #2

      Is ShellExecute (with verb "print") helpful ? Regards, Paresh.

      N 1 Reply Last reply
      0
      • P Paresh Chitte

        Is ShellExecute (with verb "print") helpful ? Regards, Paresh.

        N Offline
        N Offline
        nobaq
        wrote on last edited by
        #3

        Hi, I do not think so; I have dynamic HTML code written to my CHtmlView which I want to print the same way as with File | Print. I tried a little bit with ShellExecute but it does not work as expected. Regards, Niki

        1 Reply Last reply
        0
        • N nobaq

          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!

          J Offline
          J Offline
          Jijo Raj
          wrote on last edited by
          #4

          Use this code snippet to print your view from anywhere. The core idea is to call CView::OnCmdMsg() by passing ID_FILE_PRINT or ID_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.

          N 1 Reply Last reply
          0
          • J Jijo Raj

            Use this code snippet to print your view from anywhere. The core idea is to call CView::OnCmdMsg() by passing ID_FILE_PRINT or ID_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.

            N Offline
            N Offline
            nobaq
            wrote on last edited by
            #5

            Thank you, I think this is exactly what I was looking for :-) I'm inside my view anyway, so

            this->OnCmdMsg( ID_FILE_PRINT, 0, 0, 0 );

            does exactly what I want :-) Regards, Niki

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups