CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    13

    Headers and footers

    I'm fairly new to printing in VC, but I'm having a heckuva time getting a footer to print at the bottom of my pages. I can get it to work if I hardcode the X,Y positions, but trying to code something that will work on any paper size is getting difficult and frustrating. Anyone have examples or source for doing this?


  2. #2
    Join Date
    Apr 1999
    Posts
    396

    Re: Headers and footers

    RECT rt;
    GetClientRect(hWnd,&rt);

    then use rt.bottom as your far bottom, and rt.top as the top. THen you can figure it out pretty easily.


  3. #3
    Join Date
    Apr 1999
    Posts
    13

    Re: Headers and footers

    Actually, I finally figured it out before reading the reply. Here's the code I'm using:


    // Get the size of the printable area
    CDCSize = pDC->GetWindowExt();

    // Get current date/time and format it. Place it at the bottom left
    // of the page
    time = CTime::GetCurrentTime();
    strDateTime = time.Format(_T("Printed on %B %d, %Y at %#I:%M%p"));
    sizeString = pDC->GetTextExtent(strDateTime);

    // left-justified
    pDC->TextOut(0, -CDCSize.cy + sizeString.cy, strDateTime);

    // Print out which page we're on. Place it at the bottom right of
    // the page
    strPage.Format("Page %d of %d", m_nPage, MaxPages);
    sizeString = pDC->GetTextExtent(strPage);

    // right-justified
    pDC->TextOut(CDCSize.cx - sizeString.cx, -CDCSize.cy + sizeString.cy, strPage);




    Thanks for the help and the reply!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured