...show a horizontal scrollbar in a Listbox?
|
Autor:
Thomas Stutz |
[ Print tip
] | | |
procedure HorScrollBar(ListBox: TListBox; MaxWidth: Integer);
var
i, w: Integer;
begin
if MaxWidth = 0 then
SendMessage(ListBox.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0)
else
begin
{ get largest item }
for i := 0 to ListBox.Items.Count - 1 do
with ListBox do
begin
w := Canvas.TextWidth(Items[i]);
if w > MaxWidth then
MaxWidth := w;
end;
SendMessage(ListBox.Handle, LB_SETHORIZONTALEXTENT,
MaxWidth + GetSystemMetrics(SM_CXFRAME), 0);
end;
end;
|