|
Helpful but... for example:
var
W: Integer;
begin
W := ListBox1.Canvas.TextWidth(ListBox1.Items[0]);
SendMessage(SrcList.Handle, LB_SETHORIZONTALEXTENT, W, 0);
end;
for some reasom, the above code does not show the expected results. The resulting scroll width isn't enough to enclose a W length text line. Why?
Thanks.
EDITED:
Sorry, but i found out the solution. Maybe this can be considered as a bug.
ListBox1.Canvas.TextWidth('Hello') <> Form1.Canvas.TextWidth('Hello');
I cannot explain why but if you edit Font property of TForm1 even if ListBox1 visually draws texts with the new font, when you attempt to get TextWidth via the ListBox canvas the result are not based on the new font. Maybe because ListBox.Canvas.Font <> ListBox.Font, otherwise bug.
Note: I'm using Delphi 2007. I used Delphi 5 for years and finally i updated to 2007.
|