Board logo

Subject: 怎样给TListBox加上ScrollBars属性 [Print This Page]

Author: fql    Time: 2004-8-23 23:24     Subject: 怎样给TListBox加上ScrollBars属性

我仿照TCustomMemo的写法,但就是不行
Author: zjy    Time: 2004-8-24 13:12

可以参考一下这个函数:
// 为 Listbox 增加水平滚动条
procedure ListboxHorizontalScrollbar(Listbox: TCustomListBox);
var
  i: Integer;
  Width, MaxWidth: Integer;
begin
  Assert(Assigned(Listbox));
  MaxWidth := 0;
  for i := 0 to Listbox.Items.Count - 1 do
  begin
    Width := Listbox.Canvas.TextWidth(Listbox.Items[i]) + 4;
    if Width > MaxWidth then
      MaxWidth := Width;
  end;
  if ListBox is TCheckListBox then
    Inc(MaxWidth, GetSystemMetrics(SM_CXMENUCHECK) + 2);
  SendMessage(Listbox.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0);
end;




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0