Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#9

AW: TWinControl via TInterfacedObject via TInterfacedPersistent

  Alt 7. Jun 2018, 12:53
Wir sind davon abgekommen weil es nicht möglich war die Interface in OnSessionCreate und Konsorte mit PostMessage weiterzuleiten.
Denke mal du willst es jetzt eh nicht mehr ändern, aber mit "Weiterleiten" meinte ich im Grunde auch nur folgendes:
Delphi-Quellcode:
type
  TOnSessionCreate = procedure(...) of Object;

  TAudioVolume = class(TObject)
  strict private
    FProxy: TAudioVolumeProxy;
  strict protected
    FOnSessionCreate: TOnSessionCreate;
  public
    property OnSessionCreate: TOnSessionCreate read FOnSessionCreate write FOnSessionCreate;
  ...

  TAudioVolumeProxy = class(TInterfacedObject, IAudioVolume, IAudioSessionEvents, IMMNotificationClient, IAudioSessionNotification, IAudioEndpointVolumeCallback)
  strict prviate
    FOwner: TAudioVolume;
  strict private
    procedure OnSessionCreate(...);
  ...

constructor TAudioVolume.Create;
begin
  inherited Create;
  FProxy := TAudioVolumeProxy.Create(Self);
end;

destructor TAudioVolume.Free;
begin
  FProxy.Free;
  inherited Destroy;
end;

procedure TAudioVolumeProxy.OnSessionCreate(...)
begin
  if Assigned(FOwner.FOnSessionCreate) then
  begin
    FOwner.FOnSessionCreate(...);
  end;
end;
TAudioVolume selbst hat hierbei praktisch gar keine eigene Funktionalität, sondern dient nur als Schnitstelle (Proxy sollte man vermutlich in Implementation oder sowas umbenennen).
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat