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 Preview on Main frame in MDI Application

Print Preview on Main frame in MDI Application

Scheduled Pinned Locked Moved C / C++ / MFC
help
11 Posts 2 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.
  • H Offline
    H Offline
    Harsh Shankar
    wrote on last edited by
    #1

    Hi All, I am working on VC2008's MDI application with Ribbon bar and have to provide print preview. Now, However VC2008 do have print preview, but the client requires it to look it like the VC6.0's Print preview capturing the entire main frame along with some certain buttons, all like VC6.0. Can some body please help me on it

    HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

    S 1 Reply Last reply
    0
    • H Harsh Shankar

      Hi All, I am working on VC2008's MDI application with Ribbon bar and have to provide print preview. Now, However VC2008 do have print preview, but the client requires it to look it like the VC6.0's Print preview capturing the entire main frame along with some certain buttons, all like VC6.0. Can some body please help me on it

      HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

      S Offline
      S Offline
      sashoalm
      wrote on last edited by
      #2

      I'm not sure if it'll do what you want, but try this: Find OnFilePrintPreview in your CView-derived class and replace its code with this:

      void CYourViewDerivedClass::OnFilePrintPreview()
      {
      // AFXPrintPreview(this);

      // ASSERT_VALID(pView);

      CPrintPreviewState \*pState= new CPrintPreviewState;
      
      if (!DoPrintPreview(IDD\_AFXBAR\_RES\_PRINT\_PREVIEW, this, RUNTIME\_CLASS(CPreviewView), pState))
      {
      	TRACE0("Error: OnFilePrintPreview failed.\\n");
      	AfxMessageBox(AFX\_IDP\_COMMAND\_FAILURE);
      	delete pState;      // preview failed to initialize, delete State now
      }
      

      }

      There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

      H 1 Reply Last reply
      0
      • S sashoalm

        I'm not sure if it'll do what you want, but try this: Find OnFilePrintPreview in your CView-derived class and replace its code with this:

        void CYourViewDerivedClass::OnFilePrintPreview()
        {
        // AFXPrintPreview(this);

        // ASSERT_VALID(pView);

        CPrintPreviewState \*pState= new CPrintPreviewState;
        
        if (!DoPrintPreview(IDD\_AFXBAR\_RES\_PRINT\_PREVIEW, this, RUNTIME\_CLASS(CPreviewView), pState))
        {
        	TRACE0("Error: OnFilePrintPreview failed.\\n");
        	AfxMessageBox(AFX\_IDP\_COMMAND\_FAILURE);
        	delete pState;      // preview failed to initialize, delete State now
        }
        

        }

        There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

        H Offline
        H Offline
        Harsh Shankar
        wrote on last edited by
        #3

        Hi sashoalm, First thanks for replying... I already know the way how to prepare print preview. But i guess i was not clear enough with my requirement. My requirement is to show the preview capturing the entire main frame including all Menues, Panes, Views etc in VS 2008, how VS 6.0 does. In VS2008, the preview comes like a view only and menues etc are remain enabled.. Please suggess something else may be that will help... Thanks

        HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

        S 1 Reply Last reply
        0
        • H Harsh Shankar

          Hi sashoalm, First thanks for replying... I already know the way how to prepare print preview. But i guess i was not clear enough with my requirement. My requirement is to show the preview capturing the entire main frame including all Menues, Panes, Views etc in VS 2008, how VS 6.0 does. In VS2008, the preview comes like a view only and menues etc are remain enabled.. Please suggess something else may be that will help... Thanks

          HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

          S Offline
          S Offline
          sashoalm
          wrote on last edited by
          #4

          OK, CMainFrame should have CMainFrame::OnFilePrintPreview method, try to place the code I posted in CMainFrame::OnFilePrintPreview instead and tell me what happened.

          There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

          H 1 Reply Last reply
          0
          • S sashoalm

            OK, CMainFrame should have CMainFrame::OnFilePrintPreview method, try to place the code I posted in CMainFrame::OnFilePrintPreview instead and tell me what happened.

            There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

            H Offline
            H Offline
            Harsh Shankar
            wrote on last edited by
            #5

            Hi, Thanks for quick reply.

            sashoalm wrote:

            try to place the code I posted in CMainFrame::OnFilePrintPreview

            There is an issue in doing as you are saying but there is no such function "DoPrintPreview" in class CMDIFrameWndEx from which the CmainFrame Class is derived.. However, i already have tried:

            CView *pView = GetActiveFrame()->GetActiveView();
            if(pView == NULL)
            {
            return;
            }
            CPrintPreviewState* pState = new CPrintPreviewState;

            if (!pView->DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, pView,
            RUNTIME_CLASS(CPreviewView), pState))
            {
            delete pState; // Preview failed to initialize, delete State now.
            pState = NULL;
            }

            But it prepares the preview in the same document only and not capturing the frame. And this not what i wanted :( Please suggess something else.

            HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

            S 1 Reply Last reply
            0
            • H Harsh Shankar

              Hi, Thanks for quick reply.

              sashoalm wrote:

              try to place the code I posted in CMainFrame::OnFilePrintPreview

              There is an issue in doing as you are saying but there is no such function "DoPrintPreview" in class CMDIFrameWndEx from which the CmainFrame Class is derived.. However, i already have tried:

              CView *pView = GetActiveFrame()->GetActiveView();
              if(pView == NULL)
              {
              return;
              }
              CPrintPreviewState* pState = new CPrintPreviewState;

              if (!pView->DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, pView,
              RUNTIME_CLASS(CPreviewView), pState))
              {
              delete pState; // Preview failed to initialize, delete State now.
              pState = NULL;
              }

              But it prepares the preview in the same document only and not capturing the frame. And this not what i wanted :( Please suggess something else.

              HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

              S Offline
              S Offline
              sashoalm
              wrote on last edited by
              #6

              What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.

              There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

              H 1 Reply Last reply
              0
              • S sashoalm

                What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.

                There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                H Offline
                H Offline
                Harsh Shankar
                wrote on last edited by
                #7

                Hi Sashoalm,

                sashoalm wrote:

                What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.

                It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count.. Like in VC 6.0, i didn't needed to do any thing like that and the compiler was doing this for me, i want something like that. Thanks

                HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

                S 1 Reply Last reply
                0
                • H Harsh Shankar

                  Hi Sashoalm,

                  sashoalm wrote:

                  What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.

                  It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count.. Like in VC 6.0, i didn't needed to do any thing like that and the compiler was doing this for me, i want something like that. Thanks

                  HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

                  S Offline
                  S Offline
                  sashoalm
                  wrote on last edited by
                  #8

                  Harsh Shankar wrote:

                  It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count

                  What do you mean by that? You right-click on the ribbon bar and there's "Minimize the ribbon" *by default* in every MFC9 program. Why didn't you use that? Just do it and see how it looks. Not programatically - as a user - click on "Minimize the ribbon".

                  There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                  H 1 Reply Last reply
                  0
                  • S sashoalm

                    Harsh Shankar wrote:

                    It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count

                    What do you mean by that? You right-click on the ribbon bar and there's "Minimize the ribbon" *by default* in every MFC9 program. Why didn't you use that? Just do it and see how it looks. Not programatically - as a user - click on "Minimize the ribbon".

                    There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                    H Offline
                    H Offline
                    Harsh Shankar
                    wrote on last edited by
                    #9

                    Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.

                    HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

                    S 2 Replies Last reply
                    0
                    • H Harsh Shankar

                      Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.

                      HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

                      S Offline
                      S Offline
                      sashoalm
                      wrote on last edited by
                      #10

                      Harsh Shankar wrote:

                      we didn't have to do all those things by us and it was MFC's responsbility to do so

                      Why are you telling this to me? I'm not the author of MFC. You should send this to the guys at Microsoft ;P

                      There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                      1 Reply Last reply
                      0
                      • H Harsh Shankar

                        Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.

                        HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

                        S Offline
                        S Offline
                        sashoalm
                        wrote on last edited by
                        #11

                        I just want to clarify that I think the preview mode has just been changed in MFC 9.0 and probably there is no easy way to make it look the old way. If you don't like my suggestions then you're free not to follow them.

                        There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

                        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