Hello, i tried some FOR-methods . but i don’t get it to work. Just so i understand i have 2 listviews, one timer, and one button that enables the timer when the listview contains data.
It works nice, it play sound when the both listview matched each other, and it delete the values that doesn’t belong there, BUT the problem is , that i can’t make it stop in the right time.
Let’s say that i have added 10 values in the listview1, and all are lower than the topitem of listview2, then the ‘’while-process’’ deletes all 10 values, and if i put a code under that ‘if listview1.items =’0’ then timer1.enabled := false; it doesn’t work either :/
So how to stop the timer?
(don’t ask what the use of the program is , right now i just playing with some stuff, for learning how it works)
procedure TForm1.Timer1Timer(Sender: TObject);
var i : integer;
begin
i := listview1.Items.count;
for i:= i downto 0 do begin
while listview1.TopItem.Caption<listview2.TopItem.Caption do listview1.TopItem.Delete;
form1.caption := inttostr(listview1.items.count);
end;
if listview2.Topitem.Caption = listview1.TopItem.Caption then
begin
PlaySound(pchar(c:\sound.wav), 0, SND_FILENAME + SND_ASYNC);
listview1.TopItem.Delete;
form1.caption := inttostr(listview1.items.count);
end;
Repeat
until form1.caption ='0';
timer1.Enabled :=false;
end;
end;
It works nice, it play sound when the both listview matched each other, and it delete the values that doesn’t belong there, BUT the problem is , that i can’t make it stop in the right time.
Let’s say that i have added 10 values in the listview1, and all are lower than the topitem of listview2, then the ‘’while-process’’ deletes all 10 values, and if i put a code under that ‘if listview1.items =’0’ then timer1.enabled := false; it doesn’t work either :/
So how to stop the timer?
(don’t ask what the use of the program is , right now i just playing with some stuff, for learning how it works)
procedure TForm1.Timer1Timer(Sender: TObject);
var i : integer;
begin
i := listview1.Items.count;
for i:= i downto 0 do begin
while listview1.TopItem.Caption<listview2.TopItem.Caption do listview1.TopItem.Delete;
form1.caption := inttostr(listview1.items.count);
end;
if listview2.Topitem.Caption = listview1.TopItem.Caption then
begin
PlaySound(pchar(c:\sound.wav), 0, SND_FILENAME + SND_ASYNC);
listview1.TopItem.Delete;
form1.caption := inttostr(listview1.items.count);
end;
Repeat
until form1.caption ='0';
timer1.Enabled :=false;
end;
end;