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. MFC Printing Question

MFC Printing Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++testingbeta-testinghelp
12 Posts 5 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 Nick Parker

    I am just testing something out, this doesn't throw an error however it also doesn't print anything, am I missing something?

    void CPrintDlg::OnPrintMe()
    {
    // TODO: Add your control notification handler code here
    CDC dc;
    CPrintDialog dlg (false);
    if(dlg.DoModal() == IDOK)
    {

    	dc.Attach(dlg.GetPrinterDC());
    	DOCINFO di;
    	::ZeroMemory(&di, sizeof(DOCINFO));
    	di.cbSize = sizeof(DOCINFO);
    	di.lpszDocName = \_T("Budget Figures for the Current Fiscal Year");
    	dc.StartDoc(&di);
    
    	dc.StartPage();
    
    	CString a;
    	a = "Printing Test";
    	dc.TextOut(0, 0, a);
    	dc.EndPage();
    
    
    	dc.DeleteDC();
    }
    

    }

    Nick Parker
    May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


    N Offline
    N Offline
    Nitron
    wrote on last edited by
    #2

    You forgot:

    dc.EndDoc();

    after

    dc.EndPage();

    that may help. - Nitron


    "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

    N 1 Reply Last reply
    0
    • N Nitron

      You forgot:

      dc.EndDoc();

      after

      dc.EndPage();

      that may help. - Nitron


      "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #3

      Nitron wrote: that may help. Yep, thanks. BTW, any ideas as to why when I type ::ZeroMemory(....) I don't get intellisense? Nick Parker
      May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


      N 1 Reply Last reply
      0
      • N Nick Parker

        Nitron wrote: that may help. Yep, thanks. BTW, any ideas as to why when I type ::ZeroMemory(....) I don't get intellisense? Nick Parker
        May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


        N Offline
        N Offline
        Nitron
        wrote on last edited by
        #4

        Nick Parker wrote: when I type ::ZeroMemory(....) I don't get intellisense? I don't think it's in the global namespace. When I type "::" ZeroMemory isn't in the list. :confused: I usually dont use that function anyway, I just make sure to initialize all my variables. - Nitron


        "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

        R 1 Reply Last reply
        0
        • N Nitron

          Nick Parker wrote: when I type ::ZeroMemory(....) I don't get intellisense? I don't think it's in the global namespace. When I type "::" ZeroMemory isn't in the list. :confused: I usually dont use that function anyway, I just make sure to initialize all my variables. - Nitron


          "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #5

          Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

          N J C 3 Replies Last reply
          0
          • R Ravi Bhavnani

            Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

            N Offline
            N Offline
            Nitron
            wrote on last edited by
            #6

            If I'm using an array, I'll init:

            int d[4] = {0,1,2,3};

            if it gets too big for static init, i'll use a vector. However, you may find an un-initialized array somewhere... :~ - Nitron


            "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

            1 Reply Last reply
            0
            • R Ravi Bhavnani

              Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

              J Offline
              J Offline
              Joao Vaz
              wrote on last edited by
              #7

              Ravi Bhavnani wrote: How do you initialize an array? Err, don't you mean a structure ? You could initialize like this : DOCINFO di = {0} ; :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

              R 1 Reply Last reply
              0
              • R Ravi Bhavnani

                Nitron wrote: I usually dont use that function anyway, I just make sure to initialize all my variables. How do you initialize an array? :) /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

                C Offline
                C Offline
                Chad Koehler
                wrote on last edited by
                #8

                You can always use memset(...)

                R J 2 Replies Last reply
                0
                • C Chad Koehler

                  You can always use memset(...)

                  R Offline
                  R Offline
                  Ravi Bhavnani
                  wrote on last edited by
                  #9

                  My point was you often need to programatically initialize data using ZeroMemory() (or memset()). /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

                  1 Reply Last reply
                  0
                  • J Joao Vaz

                    Ravi Bhavnani wrote: How do you initialize an array? Err, don't you mean a structure ? You could initialize like this : DOCINFO di = {0} ; :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

                    R Offline
                    R Offline
                    Ravi Bhavnani
                    wrote on last edited by
                    #10

                    No, I meant an array. My point was ZeroMemory() comes in handy for initializing an array without having to loop through it. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

                    J 1 Reply Last reply
                    0
                    • C Chad Koehler

                      You can always use memset(...)

                      J Offline
                      J Offline
                      Joao Vaz
                      wrote on last edited by
                      #11

                      ZeroMemory is a macro to memset (&xpto,0,sizeof(xpto)) :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

                      1 Reply Last reply
                      0
                      • R Ravi Bhavnani

                        No, I meant an array. My point was ZeroMemory() comes in handy for initializing an array without having to loop through it. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

                        J Offline
                        J Offline
                        Joao Vaz
                        wrote on last edited by
                        #12

                        Ravi Bhavnani wrote: My point was ZeroMemory() comes in handy for initializing an array without having to loop through it. Ah, ok , sorry for the post . :-) Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech

                        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