[Prev][Next][Index][Thread]
Re: <text-field>, size, GDI context...
Scott Ribe <sribe@miqs.com> writes:
> I'd like to set a <text-field> width in terms of a particular string,
> not pixels. To do this I have to have a valid GDI context handle, and
> the font of the text field, then make the call to get the string width,
> and set the width of the text field accordingly.
The method 'text-size' may be useful. Maybe something like:
define method calculate-string-width( s, gadget )
let _port = gadget.port;
let style = get-default-text-style(_port, gadget);
let largest-x =
with-sheet-medium( medium = gadget )
text-size(medium, "Hello World", text-style: style);
end;
end method;
This will return the width of the string given the text style for the
gadget (assuming the gadget is a <text-field> for example). text-size
also returns other data that may be of interest (height, etc).
Chris.
Follow-Ups:
References: