"Keith G Hicks" <kr*@comcast.ne tschrieb
Accuracy is not as big an issue here as what I expect you had to
deal with on your project. They price ads based on 1.5" tall
sections. 1.5" is one price, 3" is another, and so on. If an ad were
to measure 1.51" in the code I wrote it would be billed as a 3" ad.
Now if that ad really printed up in the newspaper as a 1.5" ad they
would have of course been overbilled a bit. However, like I said,
it's not super critical. Sometimes it works the other way around.
And in addtion they make billing corrections for other things as
well. It all evens out in the end. Sometimes they're overbilled a
fraction and sometimes underbilled. The other problem is that the
calculations are done on Windows machines but all the publishing is
done on Macs. That obviuosly throws things off a bit too. We knew
from the start that it woulnd't be perfect but it's close enough
that everyone's been happy with it for sevearl years now. We just
need to get the same concept working without using Word. If we're
off by a percent or less eitehr way for any given notice, it's ok.
I have no doubts that this is all true. However, my point is still the
same as in my first reply: The actual size depends on many things. Well,
we have Graphics objects to measure text. How can we create one? A
Graphics object is a kind of wrapper to a Win32 device context. As the
name says, it refers to a device. A printer device? The screen (device)?
If you have a Winforms application, you can simply use
g=WhateverContr ol.CreateGraphi cs, do g.measuretext and there it is. I
have no other clue how to do it. If it's a web project, I don't know if
you have access to a "screen device" because everything runs in the web
server's account. Have read something about window stations and desktops
but you should better ask someone who has more experience in this.
..... Docs say: "When a noninteractive process such as a service
application attempts to connect and no window station exists for the
process logon session, the system attempts to create a window station
and desktop for the session." I read it that you can use
"Graphics.FromH wnd(Intptr.Zero )" to create a graphics object even from
within a service, then use g.measurestring .
Sry, maybe a little confusing from me today.
Armin