Autor Beitrag
Sauger Chris
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Sa 17.11.07 17:34 
moin und zwar steh ich mal wieder vor einem problem :(


und zwar möchte ich das in einer listbox eine message aus gelöst wird
sobalt ein neues item dazugkommt.


ich weiß ich bin nur noch n katzen sprung von der lösung entfernt
:)

hier mal mein code um das letzte item zu ermitteln


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Timer1Timer(Sender: TObject);
var o: integer;
begin
listbox1.Items.Clear;
GetFilesInDirectory('.\''*.txt', Listbox1.Items , False, True);   // dateien werden ausgelesen
for o:=0 to ListBox1.Items.Count-1 do
resultlog := listbox1.Items.Strings[o];
Timer2.Enabled := true;
end;



thx 4 help

chris


Zuletzt bearbeitet von Sauger Chris am Sa 17.11.07 20:33, insgesamt 3-mal bearbeitet
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 17.11.07 18:03 
Hallo,

warum alle durchgehen?
ListBox1.Items.Count-1 ist der Index des letzten Eintrags.
ausblenden Delphi-Quelltext
1:
ListBox1.Items[ListBox1.Items.Count-1];					

Wenn im Code ein Item hinzugefügt wird, hast Du doch den letzten Eintrag, oder hat sich Dein Programm verselbstständigt :wink:
ausblenden Delphi-Quelltext
1:
2:
3:
s := 'Hallo';
ListBox1.Items.Add(s);
showmessage('Der Eintrag "' + s + '" wurde hinzugefügt');

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: Sa 17.11.07 18:13 
bei mir is es so ich hab nen timer der checkt ob ne bestimte datei
(neue datei beispiel: 17.11.2007_18.10.txt) vorhanden ist
wen ja added er die neue datei in form eines items zu den anderen items in die listbox
und er soll halt nur ne massage auslösen wen auch wirklich ein neues item da ist
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 17.11.07 19:39 
Hallo,

brauchst doch nur das Hinzufügen des Items und die Message in einen begin-end-Block setzen, z.B.:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if IstDasEineNeueDatei(EineDatei) then
  begin
  ListBox1.Items.Add(EineDatei);  
  showmessage('Der Eintrag "' + EineDatei + '" wurde hinzugefügt');
  end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: So 18.11.07 09:11 
ok probieren wir es noch mal :)

also ich habe ne listbox in die alle paar sec/min durch den timer bestimte dateien namen geadded werden
und sobalt eine neue dazu kommt soll er eine massage aus lösen so
nu zum prob wen der timer nun wieder neu startet und er added wieder die selbe datei dann soll er keine message mehr aus lösen weil eine reicht ja also muß ich irgen wie vergleichen ob er bei der vorigen datei (die den gleichen name wie die neuste datei hat) schon eine message aus gelöst hat.


is bissle komisch erklärt was ich von euch will :)
wen ich die lösung hätte würde ich sie posten ;)

beispiel:(die txt datein name sind die Listbox items)
Zitat:

timer start 1x
17.11.2007_18:00.txt
17.11.2007_18:05.txt
17.11.2007_18:10.txt <---- Message auslösen


timer startet 2x
17.11.2007_18:00.txt
17.11.2007_18:05.txt
17.11.2007_18:10.txt <---- keine Message auslösen es sind noch keine neue dateien da


timer startet zum 3x

17.11.2007_18:00.txt
17.11.2007_18:05.txt
17.11.2007_18:10.txt
17.11.2007_18:15.txt <---- jetzt wieder message auslösen

usw.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8553
Erhaltene Danke: 479

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 18.11.07 11:09 
So ganz grob könnte man das so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
//globale Variable 
KnownLastItem: String;

//im Timer:
if ListBox1.Items[ListBox1.Items.Count-1] <> KnownLastItem then
begin
  KnownLastItem := ListBox1.Items[ListBox1.Items.Count-1];
  Showmessage('Was neues da');
end;

_________________
We are, we were and will not be.
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: So 18.11.07 14:36 
na das is doch mal was :)

thx Gausi das hat mir sehr geholfen :)


nur noch ne kleine frage wie handle ich am besten das error das auftritt wen kein item vorhanden ist



mfg chris
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8553
Erhaltene Danke: 479

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 18.11.07 14:37 
Den code nur ausführen, wenn Count > 0 ist ;-)

_________________
We are, we were and will not be.
Sauger Chris Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 228

Win XP, Linux SuSE 9.2
Delphi 4,Delphi 7 Ent.
BeitragVerfasst: So 18.11.07 14:39 
^^

thx :)