print page size
12 messages in this thread
GR> Can one get the size of the paper in device units (pixels)
GR> such that OnPrepareDC can set the viewport extent to be
GR> appropriate for the printer paper and not the screen?
The following will get the size of the *paper* in logical units (MM_HIENGLISH)
which can then be converted to device units via LPtoDP()…
// find out the physical page size
PRINTDLG pd;
CRect rectPaper;
if ( AfxGetApp()->GetPrinterDeviceDefaults( &pd ) )
{
ASSERT( pd.hDevMode != NULL );
LPDEVMODE ptrDevMode = ( LPDEVMODE )::GlobalLock( pd.hDevMode );
switch( ptrDevMode->dmPaperSize )
{
case 0:
// the dmPaperWidth & dmPaperLength are the width & height of
// a custom paper size expressed in 1/10's of a millimeter.
// convert to inches in MM_HIGHENGLISH…
rectPaper = CRect( 0, 0, ptrDevMode->dmPaperWidth * 4,
-ptrDevMode->dmPaperLength * 4 );
break;
case DMPAPER_LETTER:
case DMPAPER_LETTERSMALL:
case DMPAPER_NOTE:
rectPaper = (ptrDevMode->dmOrientation ==
DMORIENT_LANDSCAPE
? CRect( 0, 0, 11000, -8500 )
: CRect( 0, 0, 8500, -11000 )); //
8-1/2 x 11
break;
case DMPAPER_LEGAL:
rectPaper = ( ptrDevMode->dmOrientation ==
DMORIENT_LANDSCAPE
? CRect( 0, 0, 14000, -8500 )
: CRect( 0, 0, 8500, -14000 )); //
8-1/2 x 14
break;
default:
rectPaper = CRect( 0, 0, 0, 0 ); // handle other sizes, if
needed
break;
}
::GlobalUnlock( pd.hDevMode );
For some printers, the size of the paper and the size of the "display" (maximum
printable area) will be the same (the WinFAX driver, for example, is like
this). However others have a "hard clip" limit where tohe printer physically
cannot print. The printable area of the page can be obtained like this…
CPoint sizePrintableArea;
sizePrintableArea.x = m_pDC->GetDeviceCaps( HORZRES );
sizePrintableArea.y = m_pDC->GetDeviceCaps( VERTRES );
pDC->DPtoLP( &sizePrintableArea );
Hope this helps.
gc
Norman, Oklahoma USA
— "Is that a *real* poncho or is that a *Sears* poncho?"
>> — "Is that a *real* poncho or is that a *Sears* poncho?" <<
Perhaps if you pass Zircon Encrusted Tweezers, we could pontificate this
subject. <g>
Charles Steinhardt[MVP],
OMG Inc.
Written 09-Jul-1994 @ 21:44:34
Windows NavCIS PRO 1.21
!^NavFont01F000DMGJHGyMG{HG7D36F5
Charles,
>>> — "Is that a *real* poncho or is that a *Sears* poncho?" <<
>
>Perhaps if you pass Zircon Encrusted Tweezers, we could pontificate this
>subject. <g>
Well, I've heard of DeadHeads but what do we call you guys? Probably the
Yellow Snow People. <g>
Michael Meadows
>> but what do we call you guys? Probably the Yellow Snow People. <g> <<
How 'bout the Sons & Daughters of Florentine Pogens! …. <g>
Charles Steinhardt[MVP],
OMG Inc.
Written 10-Jul-1994 @ 13:56:11
Windows NavCIS PRO 1.21
!^NavFont01F000FMGJHG39MG3BHG6EC665
Charles,
>How 'bout the Sons & Daughters of Florentine Pogens! …. <g>
LOL. Sounds good…I'll ask Susy Creamcheese what she thinks. <g>
Michael Meadows
>> Susy Creamcheese <<
ROTF
Ahh.. suzy .. that inimitable dwarf crushing wench! Probably munching on an
Uncle meat sandwich! Ohh.. this brings back my psychedelic college (or should
I have said collage?) days.
Charles Steinhardt[MVP],
OMG Inc.
Written 10-Jul-1994 @ 20:28:10
Windows NavCIS PRO 1.21
!^NavFont01F000DMGJHGYMG_HGB115B1
Charles,
>Ahh.. suzy .. that inimitable dwarf crushing wench! Probably munching on an
>Uncle meat sandwich! Ohh.. this brings back my psychedelic college (or
>should I have said collage?) days.
It's always nice to find a kindred spirit!
Michael Meadows
"I knew you'd be surprised" – Bobby Brown/Sheik Ur B.. album
Yes, I knew you has a good perspective and sense of humour in your messages.
Congrats on the Annual award in SDK!!
Charles Steinhardt[MVP],
OMG Inc.
Written 11-Jul-1994 @ 14:18:23
Windows NavCIS PRO 1.21
!^NavFont01F0007MGHHG90F7FD
Charles,
>Congrats on the Annual award in SDK!!
Thanks…and congrats to you! I have no doubt that you will be on the first
Annual list for this forum. (Shall we form a mutual admiration society? You
pat my back and I'll pay yours. <g>)
Michael Meadows
>> You pat my back and I'll pay yours. <<
Yeah.. that's the ticket… Morgan.. uh.. yeah.. Morgan Fairchild.. she's a
big fan and voted us .. yeah and Bil..Uh Bill Gates personally is watching..
yeah ..he's gonna award us hi flat screen technology contract…
BTW, Do you havce the book Undocumented WIndows (Matt Pietrak, et.al.)?
Charles Steinhardt[MVP],
OMG Inc.
Written 11-Jul-1994 @ 22:25:47
Windows NavCIS PRO 1.21
!^NavFont01F000CMGJHGfMGhHH\2E7E
Charles,
>yeah and Bil..Uh Bill Gates personally is watching..
Oh yes, he's not only watching…he speaks to me personally through a filling
in my tooth.
>BTW, Do you havce the book Undocumented WIndows (Matt Pietrak, et.al.)?
No…why do you ask?
Michael Meadows
CS> Perhaps if you pass Zircon Encrusted Tweezers,
CS> we could pontificate this subject. <g>
Yippie-eye-oh-tye-ay, pardner 😉
gc
The dental floss tycoon of Norman, Oklahoma USA
— "Is that a *real* poncho or is that a *Sears* poncho?"