Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: Tapi Callback Funktion darf nicht in Klasse sein

  Alt 26. Nov 2012, 12:15
Delphi-Quellcode:
unit MyTapiObj;

interface

type
  TMyTapiObj = class
  protected
    procedure CalledFromCallBack;
  public
    constructor Create;
    destructor Destroy; override;
  end;

implementation

var
  _TapiInitialized : Boolean;
  _MyTapiObjList : TObjectList;

procedure TapiCallBack;
var
  LIdx : Integer;
begin
  for LIdx := 0 to Pred( _MyTapiObjList ) do
    ( _MyTapiObjList[LIdx] as TMyTapiObj ).CalledFromCallBack;
end;

procedure TapiInitialize;
begin
  if not _TapiInitialized then
  begin

    // Initialization code goes here

    _TapiInitialized := True;
  end;
end;

constructor TMyTapiObj.Create;
begin
  inherited;
  TapiInitialize;
  _MyTapiObjList.Add( Self );
end;

destructor TMyTapiObj.Destroy;
begin
  _MyTapiObjList.Remove( Self );
  inherited;
end;

initialization

  _MyTapiObjList := TObjectList.Create( False );

finalization

  _MyTapiObjList.Free;

end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat