Re: Scaling RTF text and EM_SETZOOM

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Henry Skoglund (fromnewsgroups_at_tungware.com)
Date: 07/27/04


Date: Tue, 27 Jul 2004 07:24:24 +0200

Hi, I've compiled a new version of RTFScaler (2.0 as promised!):
http://www.tungware.com/RTFScaler2.zip

What's new:
* output is clipped so that the Ok button isn't clobbered

* automagic calculation of the fudge factors, this is done
by analyzing the device metrics of the current screen, and
comparing the expected DPI with the actual DPI
(usually it's only printers that get this correct, display
drivers are likely to set the DPI to 96 no matter what your
current screen resolution is.) This should take care
of your 800x600 problem, AliR.

* by request from Vaclav, also is included 3 more
sliders for rotation and shearing.

Re: GDI+, yes I should be using that, if so then RTFScaler
would run on Windows 98 and ME as well, but the customer
which I code RTF stuff for normally (healthcare industry) is
in the process of validating Windows 2000 for my software,
and for Windows NT and 2000 GDI+ requires you to
download an extra DLL from Microsoft. It's too much
hassle, it'll have to wait until they've moved to XP, which
will most likely occur when Longhorn arrives :-(
Also, possibly some surprise might lurk around the corner
when trying to play that metafile inside GDI+!
But otherwise I like GDI+ for it's anti-aliasing capability...

Rgrds Henry

"AliR" <someone@somewhere.com> wrote in message
news:SleNc.20900$Pe7.14833@newssvr23.news.prodigy.com...
> Hi Henry,
>
> I ran into a little problem that I hope you would be able to find a solution
> to. I tried running your example in a 800x600 resolution and suddently
> things weren't working as smothly as before. In 800x600 the scale have to
> be set to around 67% for the MetaFile to paint the text at 100%. I haven't
> been able to find a solution to this problem
>
> AliR
>
> "Henry Skoglund" <fromnewsgroups@tungware.com> wrote in message
> news:uy$9BMccEHA.3012@tk2msftngp13.phx.gbl...
> > Yes, you can do rotation and sharing as well if you are using Windows NT,
> 2000, XP or
> > 2K3.
> > If you want that on Win95, 98 or ME you're out of luck, because in order
> to
> > rotate etc. you need to use world transforms. Give me a few hours, and
> I'll hack
> > together
> > a version 2.0 of RTFScaler for you! (Hmm. maybe I'll rename it to
> RTFRotater....)
> > Rgrds Henry
> >
> > P.S. To AliR, about setting the fudge factor correctly, I think I finally
> got a way to
> > settle that once and for all...
> >
> >
> > "Vaclav" <vjedlicka@nospam.please> wrote in message
> > news:uf1OqQZcEHA.3944@tk2msftngp13.phx.gbl...
> > > It is a very cool example. Is it possible to rotate the text too?
> > >
> > > Vaclav
> > >
> > > "Henry Skoglund" <fromnewsgroups@tungware.com> wrote in message
> > > news:OnsifsDcEHA.2816@TK2MSFTNGP11.phx.gbl...
> > > > Sorry I should have mentioned the fudgefactor yesterday, it's a
> leftover
> > > > from the production code, never got around to solve that.
> > > >
> > > > Yesterday, when I put together that demo project for you,
> > > > I set the fFudgeFactor to 1.315 on my new Toshiba PC in order
> > > > to get 100% to be 100% on the screen, but when I tried RTFScaler.exe
> > > > now on my server (which has a CRT monitor) I got the same result
> > > > as you did, i.e. fFudgeFactor should be 1.06.
> > > >
> > > > My guess it has to do with the specified DPI for your display driver.
> > > > It all boils down to that conversion from pixels to HiMetric in my
> > > program:
> > > > ...
> > > > pTargetDC->LPtoHIMETRIC(&cTargetSize);
> > > > ...
> > > >
> > > > That DPI setting governs how many pixels Windows thinks
> > > > will be equal to one physical inch on your display surface, as
> measured
> > > > with a ruler or equivalent tool. And the problem is that most display
> > > > drivers have a hardwired DPI of 96, regardless if the
> > > > current screen resolution is 800x600 or 1600x1200.
> > > > If you change your screen resolution, and rerun RTFScaler
> > > > with a fudge factor of 1.06, is 100% still correctly displayed?
> > > >
> > > > Rgrds Henry
> > > >
> > > >
> > > > "AliR" <someone@somewhere.com> wrote in message
> > > > news:bGULc.19078$ZG.15997@newssvr24.news.prodigy.com...
> > > > > Thanks Henry. The example helped alot. Very nice.
> > > > > I have one question about the fFudgeFactor. When I ran the program
> it
> > > had a
> > > > > value of 1.315 which made 100 scale look much larger than the
> original.
> > > So
> > > > > I went in and changed it to 1.0 to see how things would work. With
> > > > > fFudgeFactor = 1.0 it looks very close, at 106% it looks identical
> to
> > > the
> > > > > source. That is kinda of puzzeling. I was just wondering why you
> had to
> > > use
> > > > > the extra factoring. did 1.315 give you a one to one size at 100%.
> I am
> > > > > wondering if this method might have different results on different
> > > machines.
> > > > >
> > > > > Again, thanks alot for the example.
> > > > > AliR.
> > > > >
> > > > > "Henry Skoglund" <fromnewsgroups@tungware.com> wrote in message
> > > > > news:Oc$XjX4bEHA.2812@TK2MSFTNGP11.phx.gbl...
> > > > > > Ok AliR,
> > > > > > I've got a sample project for you in VS 6.0 at:
> > > > > > http://www.tungware.com/RTFScaler.zip
> > > > > >
> > > > > > Good luck with this!
> > > > > > Rgrds Henry
> > > > > >
> > > > > >
> > > > > > "AliR" <someone@somewhere.com> wrote in message
> > > > > > news:itBLc.17190$_u.10480@newssvr23.news.prodigy.com...
> > > > > > > either one should be good, I have VS 6.0 and .Net2002
> > > > > > >
> > > > > > > Thanks
> > > > > > > AliR
> > > > > > >
> > > > > > > "Henry Skoglund" <fromnewsgroups@tungware.com> wrote in message
> > > > > > > news:%23gJP6l2bEHA.796@TK2MSFTNGP09.phx.gbl...
> > > > > > > > I had a quick look and I only found production code, but I
> could
> > > whip
> > > > > up
> > > > > > > > a quick example for you.
> > > > > > > > I have Visual Studio 6 and Visual Studio 2005 Beta 1, which
> one
> > > > > > > > works best for you?
> > > > > > > > (I've uninstalled Visual Studio .NET 2003, the 2005 Beta 1 is
> so
> > > > > > > > much better for C++ in my opinion...)
> > > > > > > > /Henry
> > > > > > > >
> > > > > > > >
> > > > > > > > "AliR" <someone@somewhere.com> wrote in message
> > > > > > > > news:_VALc.17185$nm.10429@newssvr23.news.prodigy.com...
> > > > > > > > > Thanks for the info Henry.
> > > > > > > > > I have never used Metafiles before. I am going to give it a
> > > try.
> > > > > > > > > If you get a chance can you post a quick example?
> > > > > > > > >
> > > > > > > > > thanks
> > > > > > > > > AliR
> > > > > > > > >
> > > > > > > > > "Henry Skoglund" <fromnewsgroups@tungware.com> wrote in
> message
> > > > > > > > > news:OOZLeY2bEHA.3012@tk2msftngp13.phx.gbl...
> > > > > > > > > > Hi, I tried a lot of tricks to scale RTF text until I
> realized
> > > the
> > > > > > > best
> > > > > > > > > > approach is in 2 steps:
> > > > > > > > > > first create a memory metafile and render the RTF text
> into it
> > > > > (scale
> > > > > > > is
> > > > > > > > > > still 1:1) and then
> > > > > > > > > > play that metafile into your DC (I use SetWorldTransform()
> to
> > > > > scale
> > > > > > > but
> > > > > > > > > > other
> > > > > > > > > > methods should work as well).
> > > > > > > > > >
> > > > > > > > > > "AliR" <someone@somewhere.com> wrote in message
> > > > > > > > > > news:0qALc.17127$Xa.6382@newssvr23.news.prodigy.com...
> > > > > > > > > > > Hi everyone,
> > > > > > > > > > >
> > > > > > > > > > > I am trying to find a way to cleanly scale some RTF text
> > > that I
> > > > > want
> > > > > > > to
> > > > > > > > > > draw
> > > > > > > > > > > on a DC. The only way I found to draw RTF on to a dc is
> to
> > > use
> > > > > > > > > > > CRichEditCtrl::FormatRange (which is nice) but how would
> I
> > > scale
> > > > > the
> > > > > > > > > > image.
> > > > > > > > > > > I tried using EM_SETZOOM which is supposed to be
> avaliable
> > > with
> > > > > > > richedit
> > > > > > > > > > 3.0
> > > > > > > > > > > and above. But it's not working.
> > > > > > > > > > >
> > > > > > > > > > > So as a test i created a dialog with a CRichEditCtrl
> > > > > > > > > > > I send the EM_SETZOOM message to the control, with 6:1
> to
> > > make
> > > > > the
> > > > > > > text
> > > > > > > > > 6
> > > > > > > > > > > times bigger,
> > > > > > > > > > > then I turn around and ask it for it's zoom, and it says
> > > that it
> > > > > is
> > > > > > > 6:1,
> > > > > > > > > > but
> > > > > > > > > > > the text within the window is not scaled at all.
> > > > > > > > > > >
> > > > > > > > > > > Thanks
> > > > > > > > > > > AliR
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Quantcast