Browse Source

* Added IInterface to TComponent

michael 7 years ago
parent
commit
355818cd00
1 changed files with 24 additions and 1 deletions
  1. 24 1
      packages/rtl/classes.pas

+ 24 - 1
packages/rtl/classes.pas

@@ -516,7 +516,7 @@ type
     property Current: TComponent read GetCurrent;
   end;
 
-  TComponent = class(TPersistent)
+  TComponent = class(TPersistent, IInterface)
   private
     FOwner: TComponent;
     FName: TComponentName;
@@ -555,12 +555,16 @@ type
     procedure ValidateRename(AComponent: TComponent;  const CurName, NewName: string); virtual;
     procedure ValidateContainer(AComponent: TComponent); virtual;
     procedure ValidateInsert(AComponent: TComponent); virtual;
+  protected
+    function _AddRef: Integer;
+    function _Release: Integer;
   public
     constructor Create(AOwner: TComponent); virtual; reintroduce;
     destructor Destroy; override;
     procedure BeforeDestruction; override;
     procedure DestroyComponents;
     procedure Destroying;
+    function QueryInterface(const IID: TGUID; out Obj): integer; virtual;
 //    function ExecuteAction(Action: TBasicAction): Boolean; virtual;
     function FindComponent(const AName: string): TComponent;
     procedure FreeNotification(AComponent: TComponent);
@@ -3528,6 +3532,16 @@ begin
   if AComponent=nil then ;
 end;
 
+function TComponent._AddRef: Integer;
+begin
+  Result:=-1;
+end;
+
+function TComponent._Release: Integer;
+begin
+  Result:=-1;
+end;
+
 
 Constructor TComponent.Create(AOwner: TComponent);
 
@@ -3601,6 +3615,15 @@ begin
       TComponent(FComponents.Items[Runner]).Destroying;
 end;
 
+function TComponent.QueryInterface(const IID: TGUID; out Obj): integer;
+begin
+  if GetInterface(IID, Obj) then
+    Result := S_OK
+  else
+    Result := E_NOINTERFACE;
+
+end;
+
 
 Function  TComponent.FindComponent(const AName: string): TComponent;