CnPack Forum


 
Subject: 怎样给TListBox加上ScrollBars属性
fql
新警察
Rank: 1



UID 485
Digest Posts 0
Credits 1
Posts 1
点点分 1
Reading Access 10
Registered 2004-8-23
Status Offline
Post at 2004-8-23 23:24  Profile | Blog | P.M. 
怎样给TListBox加上ScrollBars属性

我仿照TCustomMemo的写法,但就是不行
Top
zjy
管理员
Rank: 9Rank: 9Rank: 9



UID 2
Digest Posts 6
Credits 2385
Posts 1543
点点分 2385
Reading Access 102
Registered 2002-12-16
Location China
Status Offline
Post at 2004-8-24 13:12  Profile | Site | Blog | P.M. 
可以参考一下这个函数:
// 为 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;




Zhou JingYu
CnPack Administrator
http://www.cnpack.org/
Top
 




All times are GMT++8, the time now is 2024-11-24 13:07

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007039 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP