Simon Huggins mentioned this to Martin Maat:
SH> procedure Tdiaryfrm.left_listMeasureItem (Control: TWinControl;
SH> Index: Integer; var Height: Integer);
SH> var
SH> temp:string;
SH> t:pchar;
SH> r:Trect;
SH> begin
SH> temp:=(control as Tlistbox).items[index];
SH> t:=stralloc(length(temp)+2);
SH> strpcopy(t,temp);
SH> with (control as Tlistbox).canvas do
SH> r:=rect(left,0,left+width,height);
SH> Height:=drawtext( hwnd(control), t, -1, r , DT_WORDBREAK+DT_CALCRECT);
SH> strdispose(t);
SH> end;
A control is not a handle. Try this:
procedure Tdiaryfrm.left_listMeasureItem (Control: TWinControl;
Index: Integer; var Height: Integer);
var
Item : string;
r : TRect;
begin
Item := (Control as Tlistbox).Items[Index];
with (Control as Tlistbox).Canvas do
r := Bounds(Left, 0, Width, Height);
Height:= DrawText(Control.Handle,
@Item[1],
Length(Item),
r,
DT_WORDBREAK+DT_CALCRECT);
end;
procedure Tdiaryfrm.left_listDrawItem(Control: TWinControl; Index:
Integer; Rect: TRect; State: TOwnerDrawState);
var
Item : string;
begin
Item := (Control as Tlistbox).Items[Index];
DrawText(Control.Handle, @Item[1], Length(Item), Rect, DT_WORDBREAK);
d;
...Gary
--- GoldED 2.41
---------------
* Origin: Nobody expects the Flying Circus BBS! (1:2410/905)
|