|
-
May 20th, 1999, 02:41 PM
#1
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?
-
May 20th, 1999, 10:58 PM
#2
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.
-
May 21st, 1999, 09:01 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|