title: Overriding method of a component in Delphi 7?
body: <p>Basing on <a href="https://stackoverflow.com/a/14783549">this</a> answer I'm trying to override <code>OnShowWindow</code> method of <code>TOleContainer</code> in Delphi 7. </p>
  
  <pre><code>unit MyOleContainer;
  
  interface
  
  uses
      Windows, OleCtnrs;
  
  type
    TOleContainer = class(OleCtnrs.TOleContainer)
    private
      function OnShowWindow(fShow: BOOL): HResult; stdcall; override;
    end;
  
  implementation
  
  function TOleContainer.OnShowWindow(fShow: BOOL): HResult;
  begin
     Result := S_OK;
  end;
  
  end.
  </code></pre>
  
  <p>But this won't compile giving following error: <code>[Error] MyOleContainer.pas(11): Field definition not allowed after methods or properties</code> Why?</p>
  
  <p>Edit:</p>
  
  <p>Could you please explain how to "declare implementation of IOleClientSite, inherit from TOleContainer and hide the method OnShowWindow [...] use a TOleContainer as IOleClientSite"?</p>
  
  <p>Edit2:</p>
  
  <p>Is this what you meant?</p>
  
  <pre><code>TMyContainer = class(TOleContainer, IOleClientSite)
  private 
     FIOleClientSite: IOleClientSite;
     function SaveObject: HResult; stdcall;
     ...
  
  constructor TMyContainer.Create(AOwner: TComponent);
  begin
    inherited Create(AOwner);
    Self.OleObjectInterface.GetClientSite(FIOleClientSite);
  end;
  
  function TMyContainer.SaveObject: HResult;
  begin
    Result := FIOleClientSite.SaveObject;
  end;
  
  ...
  </code></pre>