15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Fonts in OnBeginPrinting & OnPrint

Mike Kurtinitis -- moosh@halcyon.com
Saturday, October 19, 1996

Environment: VC++ 4.0, Windows95

Hello,

I've noticed that the CDC passed to OnBeginPrinting has a different font
than the one passed to OnPrint. Is there any way I can control this since it
has ramifications in my page calculation code. In OnBeginPrinting I walk a
list of strings and use CDC::DrawText() to calculate the rectangles they
draw into, caching them as I go. Later, in OnPrint(), I position the
rectangles and draw the text into them. But because the font changes, the
rectangles aren't accurate anymore so print preview displays things not as
they "should" be. I'd appreciate any suggestions that might get me past this.

Thanks in advance,

-Mike Kurtinitis
Mooshwerks
moosh@halcyon.com




robmanderson@unn.unisys.com
Tuesday, October 22, 1996

[Mini-digest: 2 responses]

Easily fixed....
 Simply select the same font into both device contexts - never rely on the 
default font - I make this a cardinal rule in my own code.

Rob
---
Environment: VC++ 4.0, Windows95

Hello,

I've noticed that the CDC passed to OnBeginPrinting has a different font
than the one passed to OnPrint. Is there any way I can control this since it
has ramifications in my page calculation code. In OnBeginPrinting I walk a
list of strings and use CDC::DrawText() to calculate the rectangles they
draw into, caching them as I go. Later, in OnPrint(), I position the
rectangles and draw the text into them. But because the font changes, the
rectangles aren't accurate anymore so print preview displays things not as
they "should" be. I'd appreciate any suggestions that might get me past this.

Thanks in advance,

-Mike Kurtinitis
Mooshwerks
moosh@halcyon.com
 


-----From: ganeshs@nationwide.com

  Unisys Corp
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
> Hello,
>
> I've noticed that the CDC passed to OnBeginPrinting has a different font
> than the one passed to OnPrint. Is there any way I can control this since it
> has ramifications in my page calculation code. In OnBeginPrinting I walk a
> list of strings and use CDC::DrawText() to calculate the rectangles they

    You mean GetTextExtent(), right?

[Moderator's note: No, he means DrawText().  Read the documentation and
look for the word DT_CALCRECT.]

> draw into, caching them as I go. Later, in OnPrint(), I position the
> rectangles and draw the text into them. But because the font changes, the
> rectangles aren't accurate anymore so print preview displays things not as
> they "should" be. I'd appreciate any suggestions that might get me past this.
>
> Thanks in advance,

    Do you  select in the  desired font,  (with which you  calculate the
"extents" in  OnBeginPrinting()) in OnPrint() (or  in OnPrepareDC()...)?
StartPage() (which the framework calls before the call to OnPrepareDC())
_resets_ the  DC attributes to _default_  values. So you need  to modify
the  DC attributes,  (if  you require  non-default  values, that  is...)
before rendering each page...

/ ___|    / ___| __ _ _ __   ___  ___| |    I do not speak for
\___ \   | |  _ / _` | '_ \ / _ \/ __| '_ \ Tata   Unisys   or
 ___) |  | |_| | (_| | | | |  __/\__ \ | | |Nationwide    Ins.
|____(_)  \____|\__,_|_| |_|\___||___/_| |_|------------------



Karl Edwall -- karl@hs.com.au
Wednesday, October 23, 1996

[Mini-digest: 2 responses]

Mike Kurtinitis wrote:
> Environment: VC++ 4.0, Windows95
> 
> Hello,
> 
> I've noticed that the CDC passed to OnBeginPrinting has a different font
> than the one passed to OnPrint. Is there any way I can control this since it
> has ramifications in my page calculation code. In OnBeginPrinting I walk a
> list of strings and use CDC::DrawText() to calculate the rectangles they
> draw into, caching them as I go. Later, in OnPrint(), I position the
> rectangles and draw the text into them. But because the font changes, the
> rectangles aren't accurate anymore so print preview displays things not as
> they "should" be. I'd appreciate any suggestions that might get me past this.
> 
> Thanks in advance,
> 
> -Mike Kurtinitis
> Mooshwerks
> moosh@halcyon.com
> 

You have to create the font you want beforehand (or in OnBeginPrinting)
and select the font into the CDC in both places.

---------------------------------------
Human Solutions Pty Ltd
DATA + PEOPLE = INFORMATION
Ph: (03) 62335536    Fax: (03) 62335535
Karl Edwall - karl@hs.com.au

-----From: David Little 

How about GetTextExtentPoint32()?, and use CDC::IsPrinting() to
determine what to do....

David





| Вернуться в корень Архива |