delphi - How to get pixel width and height of String? -


how use gettextextentpoint32w in delphi 7 pixel width , height of wide string before output?

you can do

procedure tform1.formpaint(sender: tobject); var   extent: tsize;   s: widestring; begin   s := 'this integral sign: '#$222b;   if not gettextextentpoint32w(canvas.handle, pwidechar(s), length(s), extent)     raiselastoserror;   textoutw(canvas.handle, (width - extent.cx) div 2, (height - extent.cy) div 2,     pwidechar(s), length(s)); end; 

the gettextextentpoint32w place width , height in extent.cx , extent.cy, respectively.

the last line use textoutw draw string centered both horizontally , vertically on client area.


Comments