楼上的方法我也试过,不行的; procedure TForm1.Timer1Timer(Sender: TObject); begin if listbox1.ItemIndex<listbox1.Count-1 then listbox1.Selected[listbox1.ItemIndex+1]:= true else listbox1.Selected[0]; SetScrollPos(Listbox1.Handle,SB_VERT,listBox1.ItemIndex,True); end;
Shift: TShiftState; X, Y: integer);
begin
FNListbox.ItemIndex := FNListbox.ItemAtPos(Point(X, Y), true)
end;
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
SetScrollPos(Listbox1.Handle,SB_VERT,listBox1.ItemIndex,True);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if listbox1.ItemIndex<listbox1.Count-1 then
listbox1.Selected[listbox1.ItemIndex+1]:= true else listbox1.Selected[0];
SetScrollPos(Listbox1.Handle,SB_VERT,listBox1.ItemIndex,True);
end;
SetScrollPos(Listbox1.Handle,SB_VERT,listBox1.ItemIndex,True);//修改listBox1.ItemIndex这个参数,比如,listBox1.ItemIndex+3,就是滚动到他的后三个,不过你要控制是否到了最后,
该能明白点了吧
SetScrollPos(Listbox1.Handle,SB_VERT,listBox1.Count,True);
它是滚动到我列表显示区域的最后,
而不是我列表中最后的一条记录。
:)
procedure TForm1.Timer1Timer(Sender: TObject);
var
MyRect: TRect;
Mypos: TPoint;
y1: Integer;
begin
Timer1.Enabled := False;
if ListBox1.ItemIndex < ListBox1.Count - 1 then
ListBox1.ItemIndex := ListBox1.ItemIndex + 1
else ListBox1.ItemIndex := 0; MyRect := ListBox1.ItemRect(ListBox1.ItemIndex);
Mypos := MyRect.TopLeft;
y1 := ListBox1.Height div 2; if MyPos.Y >= y1 then
postMessage(ListBox1.Handle,WM_VSCROLL,SB_LINEDOWN,0);
Timer1.Enabled := True;
end;