Click to See Complete Forum and Search --> : Headers and footers
The Iceman
May 20th, 1999, 02:41 PM
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?
Todd Jeffreys
May 20th, 1999, 10:58 PM
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.
The Iceman
May 21st, 1999, 09:01 AM
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!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.