Hallo,
ich habe gestern angefangen eine eigene listbox zu schreiben mit TCanvas.
Jetzt habe ich ein problem mit dem scrollen, hier der code:
Delphi-Quellcode:
procedure Tmylistbox.Draw;
var
i:Integer;
s:Char;
y:Integer;
begin
HeaderCaption.DrawCaption('',-1,-1);
FootCaption.DrawCaption(IntTostr(itemIndex)+'\'+IntTostr(Items.count) ,-1,-1);
Paint.DrawRect(posX,posY,200,150);
s:=#0; y:=-1;
if items <> NIL then begin
for i:=0 to items.count-1 do begin
with TmyListItem(Items.Items[i]) do begin
if Caption.isSel = True then begin
s:='*';
SetIndex(i);
FootCaption.fCaption:='Einträge: ' + IntTostr(itemIndex)+'\'+IntTostr(Items.count)+'\' + IntTostr(displaycount) ;
end
else begin
s:=' ';
SetIndex(-1);
end;
if (items.count-1 > displaycount) and (ScrollIndex > 0) and (Caption.fPos.y >displayh) then begin
if Caption.fPos.y > posY+displayh then
y:=(posy+Caption.fPos.y)-(posY+displayh)
else
y:=-1;
if y <= 200 then
Caption.DrawCaption(s,-1,y);
end
else begin
if (items.count-1 <= displaycount) or (scrollindex = 0) then
if i <=displaycount then
Caption.DrawCaption(s,-1,-1);
end;
end;
end;
end;
FootCaption.DrawCaption('' ,-1,-1);
// FootCaption.fCaption:='Einträge: ' + IntTostr(itemIndex)+'\'+IntTostr(Items.count);
end;
displaycount = Anzahl der angezeigten items
DisplayH = die Fläche in der angezeigt werden kann(die vertikale fläche)
posx, posy:= listbox position
das problem ist jetzt: es wird zwar richtig gezeichnet nur ich weiß noch nicht so recht wie ich es stuern kann, also ich möchte das scrollen beinflussen und genau das ist das problem:
einmal möchte ich über einen scrollbalken und einmal über den itemIndex. kann mir jemmand tipps geben wie das gehen könnte?