Autor Beitrag
P-A-L
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Do 11.09.08 19:36 
Hallo nochmal,

erstmal herzlichen Dank für eure Hilfe bei meinem anderen Problem! :)

Ich habe eine ListView, für deren SelectItem-Event eine Routine ausgeführt wird - so weit so gut. Durch die Tests mit ShowMessage ist mir aufgefallen, dass dieses Event bis zu vier Mal ausgelöst wird, wenn man das zweite Mal ein Element markiert. Das heißt beim ersten Mal wird sie "nur" zweimal durchlaufen, wenn man dann aber ein anderes (oder auch dasselbe?) Item auswählt, bekomme ich bis zu vier Meldungen aus nur einer einzigen ShowMessage Anweisung...

Kann es sein, dass ich das falsche Ereignis verwende? Ich möchte eine Prozedur ausführen, wenn ein Element des ListView ausgewählt wurde.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TGrafikForm.ListView_UnitsSelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
var
  _aUnit:MWW2_Unit;
begin
  ShowMessage('Meldung');
  _aUnit:=MWW2_Unit(MWW2_Game.Instance.getUnit(Item.SubItems[0]));
  IF _aUnit=NIL Then Label1.Caption:='Unit '+Item.SubItems[0]+' could not be found!'
  ELSE BEGIN
    Label1.Caption:=_aUnit.ID;
    Memo_BtnDetail.Lines.Add('Versuche Text hinzuzufügen');
    ShowUnitDetails(_aUnit);
  END;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 11.09.08 20:27 
Moin!

user profile iconP-A-L hat folgendes geschrieben:
Kann es sein, dass ich das falsche Ereignis verwende? Ich möchte eine Prozedur ausführen, wenn ein Element des ListView ausgewählt wurde.
Nein, das ist schon alles OK so. ;)
ausblenden Delphi-Quelltext
1:
procedure TGrafikForm.ListView_UnitsSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);					
Schonmal den 2. Parameter bemerkt? :)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.