delphi - How do I draw Unicode text? -


how draw unicode text on tcustomcontrol? there other options make without canvas?

yes, right on spot. still, recommend upgrade delphi 2009 or later in vcl has full unicode support , easier.

anyhow, can do

procedure tmycontrol.paint; var   s: widestring;   r: trect; begin   inherited;   r := clientrect;   s := 'this integral sign: '#$222b;   drawtextw(canvas.handle, pwidechar(s), length(s), r, dt_singleline or     dt_center or dt_vcenter or dt_end_ellipsis); end; 

in old versions of delphi (i think. code compiles in delphi 7 in virtual windows 95 machine, see no text. because windows 95 old, think.)

update

if want support old operating systems, windows 95 , windows 98, need use textoutw instead of drawtextw, since latter isn't implemented (source). textout less powerful drawtext, need compute position manually if want center text inside rectangle, instance.

procedure tmycontrol.paint; var   s: widestring; begin   inherited;   s := 'this integral sign: '#$222b;   textoutw(canvas.handle, 0, 0, pwidechar(s), length(s)); end; 

Comments