Ver Mensaje Individual
  #2  
Antiguo 12-08-2013
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 23
maeyanes Va por buen camino
Hola...

Podrías saberlo si en la clase tienes alguna forma de hacer referencia al TObjectList en cuestión, de otra forma, tendrías que crear una propiedad donde guardes ese índice:

Código Delphi [-]
// 1era opción:
TMyObject = class(TObject)
private
  FObjectList: TObjectList;

  function GetIndex: Integer;
public
  property ObjectList: TObjectList read FObjectList write FObjectList;
  property Index: Integer read GetIndex;
end;

implementation

function TMyObject.GetIndex: Integer;
begin
  if Assigned(FObjectList) then
    Result := FObjectList.IndexOf(Self)
  else
    Result := -1
end;

// Ejemplo:
MyObject := TMyObject.Create;
MyObject.ObjectList := AObjectList;
AObjectList.Add(MyObject);

// 2da opción:
TMyObject = class(TObject)
private
  FIndex: Integer;
public
  property Index: Integer read FIndex write FIndex;
end;

// Ejemplo:
MyObject := TMyObject.Create;
MyObject.Index := AObjectList.Add(MyObject);


Saludos...
__________________
Lee la Guía de Estilo antes que cualquier cosa. - Twitter
Responder Con Cita