Jun 25, 2002 #1 dds82 Programmer Jun 5, 2002 251 US I'm trying to print something. How do I calculate the number of lines that fit on a page? Thanks.
Jun 26, 2002 #2 JCARPENTER Programmer Mar 30, 2000 8 US Assuming you have a device context for the printer and that you've selected a mapping mode and a font into it: 1. Get the physical length of the page: int iHorzRes = pDC->GetDeviceCaps(HORZSIZE); 2. Convert the resolution into the map mode (This app uses MM_LOENGLISH, so the conversion is to 100ths of an inch): iHorzRes = int(( float(iHorzRes) / 25.4f ) * float(100)); 3. Get the height of the currently selected font: TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int iCharHt = abs(tm.tmHeight); 4. The number of lines is the horizontal length divided by the character height. JLC Upvote 0 Downvote
Assuming you have a device context for the printer and that you've selected a mapping mode and a font into it: 1. Get the physical length of the page: int iHorzRes = pDC->GetDeviceCaps(HORZSIZE); 2. Convert the resolution into the map mode (This app uses MM_LOENGLISH, so the conversion is to 100ths of an inch): iHorzRes = int(( float(iHorzRes) / 25.4f ) * float(100)); 3. Get the height of the currently selected font: TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int iCharHt = abs(tm.tmHeight); 4. The number of lines is the horizontal length divided by the character height. JLC
Jun 27, 2002 Thread starter #3 dds82 Programmer Jun 5, 2002 251 US What about other mapping modes? Upvote 0 Downvote