给ListBox添加一个横滚动条?(100分)

L

lwluser

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用SendMessage来给ListBox添加一个横的滚动条,哪位大虾
知道要用哪个消息,请帮帮小第?
 

var
i, MaxWidth: integer;
begin
MaxWidth := 0;
for i := 0 to ListBox1.Items.Count - 1do
if MaxWidth < ListBox1.Canvas.TextWidth(ListBox1.Items.Strings) then
MaxWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings);
SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, MaxWidth+150, 0);
end;

或者继承TListBox写一个
看看这里,改一下就行了
http://www.delphibbs.com/delphibbs/dispq.asp?lid=691355
 
首先添加滚动条:
procedure TListBoxEx.CreateParams(var Params:TCreateParams)
begin
inherited CreateParams(Params);
Params.Style:=Params.Style or ws_HScroll;
end;
然后再处理追加、插入、删除的事件,消息分别是lb_ADDString、lb_InsertString、lbDeleteString
 
直接换行得了。呵呵,用我那个问题的答案,你找找,我刚结的贴子。
http://delphibbs.com/delphibbs/dispq.asp?lid=1479220
相应够你用了。
 
接受答案了.
 

Similar threads

回复
0
查看
652
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
458
DelphiTeacher的专栏
D
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部