Click here to Skip to main content
15,909,530 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPrinting Pin
#realJSOP9-Feb-06 9:11
professional#realJSOP9-Feb-06 9:11 
AnswerRe: Printing Pin
David Crow9-Feb-06 9:14
David Crow9-Feb-06 9:14 
GeneralRe: Printing Pin
#realJSOP9-Feb-06 9:31
professional#realJSOP9-Feb-06 9:31 
AnswerRe: Printing Pin
Shog99-Feb-06 11:45
sitebuilderShog99-Feb-06 11:45 
AnswerRe: Printing Pin
Michael Dunn9-Feb-06 10:14
sitebuilderMichael Dunn9-Feb-06 10:14 
GeneralRe: Printing Pin
#realJSOP10-Feb-06 5:26
professional#realJSOP10-Feb-06 5:26 
GeneralRe: Printing Pin
#realJSOP10-Feb-06 10:13
professional#realJSOP10-Feb-06 10:13 
AnswerRe: Printing Pin
Stan Shannon9-Feb-06 13:54
Stan Shannon9-Feb-06 13:54 
Petzold introduced a technique for achieving true WYSIWYG printing way back in the late '80s. I used it in about 1993 with good results. Unfortunantly, I no longer have that code, or the book. The technique was called 'logical twips' and involved a formuila for adjusting the mapping mode to work for both the screen and the printer device context.
The "Logical Twips" Mapping Mode [^]

When I discussed mapping modes in Chapter 11, you might have thought the
MM_TWIPS mapping mode would be used by programs that make heavy use of
formatted text. In this mapping mode, logical units are in terms of 1/20
point. However, you probably won't want to use MM_TWIPS for the video
display, because the mapping mode is based on real inches rather than
logical inches. As a result, your program won't be able to equate the
correct point sizes (8, 10, 12, 14, 18, and 24) of the available screen
fonts to their heights in MM_TWIPS units.

You'll be better off if you define your mapping mode based on the
logical-pixels-per-inch dimensions available from GetDeviceCaps. I call this
the "Logical Twips" mapping mode; here's all you need to set it:

SetMapMode (hdc, MM_ANISOTROPIC) ;
SetWindowExt (hdc, 1440, 1440) ;
SetViewportExt (hdc, GetDeviceCaps (hdc, LOGPIXELSX),
GetDeviceCaps (hdc, LOGPIXELSY)) ;

Because the pixels-per-logical-inch values are always divisors of 1440, the
scaling factor for this mapping mode is an integer. With this mapping mode
set, if you want to request a font with 12-point line spacing (as we'll do
shortly), you can specify the height of the font as 240 (12 times 20)
logical units.

If you select a font into your device context and call GetTextMetrics to
obtain the dimensions of the font, you can calculate the type size in points
by using the formula:

(tm.tmHeight - tm.tmInternalLeading) / 20

The line spacing in points is equal to:

tm.tmHeight / 20

For some smaller fonts on low-resolution devices, the size and spacing of
the type might actually involve a fraction of a point--for example, 8-point
type with 8.5-point line spacing. To round to the nearest integer point
size, you might instead want to use the formulas:

(tm.tmHeight - tm.tmInternalLeading + 10) / 20

and:

(tm.tmHeight + 10) / 20

We'll use the "Logical Twips" mapping mode in the JUSTIFY program toward the
end of this chapter.

Once again, remember that the discrepancy between logical inches and real
inches occurs only for the display. If you use the "Logical Twips" mapping
mode with a printer, you'll simply duplicate the MM_TWIPS mapping mode.


"You get that which you tolerate"

-- modified at 19:55 Thursday 9th February, 2006
QuestionHow to disable all controls in the dialog box Pin
Eugene Pustovoyt9-Feb-06 8:39
Eugene Pustovoyt9-Feb-06 8:39 
AnswerRe: How to disable all controls in the dialog box Pin
Andy Moore9-Feb-06 9:14
Andy Moore9-Feb-06 9:14 
QuestionRe: How to disable all controls in the dialog box Pin
David Crow9-Feb-06 9:15
David Crow9-Feb-06 9:15 
AnswerRe: How to disable all controls in the dialog box Pin
#realJSOP9-Feb-06 10:09
professional#realJSOP9-Feb-06 10:09 
AnswerRe: How to disable all controls in the dialog box Pin
jhwurmbach10-Feb-06 3:27
jhwurmbach10-Feb-06 3:27 
QuestionMultithreaded Programming Pin
RanjanShrestha9-Feb-06 8:07
RanjanShrestha9-Feb-06 8:07 
AnswerRe: Multithreaded Programming Pin
Rage9-Feb-06 8:13
professionalRage9-Feb-06 8:13 
GeneralRe: Multithreaded Programming Pin
RanjanShrestha9-Feb-06 8:17
RanjanShrestha9-Feb-06 8:17 
GeneralRe: Multithreaded Programming Pin
Rage9-Feb-06 8:31
professionalRage9-Feb-06 8:31 
Questiona little output problem Pin
Peter Charlesworth9-Feb-06 7:46
Peter Charlesworth9-Feb-06 7:46 
AnswerRe: a little output problem Pin
Rage9-Feb-06 8:15
professionalRage9-Feb-06 8:15 
QuestionGetting CXX0030: Error: expression cannot be evaluated Pin
zahid_ash9-Feb-06 7:34
zahid_ash9-Feb-06 7:34 
QuestionRe: Getting CXX0030: Error: expression cannot be evaluated Pin
David Crow9-Feb-06 7:42
David Crow9-Feb-06 7:42 
AnswerRe: Getting CXX0030: Error: expression cannot be evaluated Pin
Rage9-Feb-06 7:44
professionalRage9-Feb-06 7:44 
Questionminimizing or hiding the DOS window in VC++ exe application Pin
sashabkvs9-Feb-06 6:32
sashabkvs9-Feb-06 6:32 
AnswerRe: minimizing or hiding the DOS window in VC++ exe application Pin
Rage9-Feb-06 7:11
professionalRage9-Feb-06 7:11 
QuestionRe: minimizing or hiding the DOS window in VC++ exe application Pin
David Crow9-Feb-06 7:12
David Crow9-Feb-06 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.