title: Component Creation - Joining Components Together?
body: <p>I am new to component creation and was experimenting with creating some of my own custom derived components using the standard issue VCL from Delphi.</p>
  
  <p>I thought I could mix two components together, to create one singular one. Take below what I have so far, the idea is to put a TImage inside a TScrollBox:</p>
  
  <pre><code>unit MyComponent;
  
  interface
  
  uses
    Windows,
    Classes, 
    Controls,
    Forms,
    ExtCtrls;
  
  type
    TMyPanel = class(TScrollBox)
    public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
    end;
  
  procedure Register;
  
  implementation
  
  procedure Register;
  begin
    RegisterComponents('Standard', [TMyPanel]);
  end;
  
  { TMyPanel }
  
  constructor TMyPanel.Create(AOwner: TComponent);
  var
    AImage: TImage;
  begin
    inherited Create(AOwner);
  
    AImage := TImage.Create(AOwner);
    AImage.Align := alClient;
    AImage.Parent := Self;
  end;
  
  destructor TMyPanel.Destroy;
  begin
    inherited;
  end;
  
  end.
  </code></pre>
  
  <p><strong><em>If I compile and install the above into a package, the result is as shown below:</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/LvAi2.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/uZ0VF.png" alt="enter image description here"></p>
  
  <p><strong>Problem</strong></p>
  
  <p>I would like my component to be registered as one single component. But the component should be a combination of both TScrollBox and TImage. The main component will be the TScrollBox, but it should now have access to the properties and events etc of the TImage aswell.</p>
  
  <p>For example, TMyPanel could share the properties of TImage and TScrollBox together:</p>
  
  <ul>
  <li>AutoSize</li>
  <li>BorderStyle</li>
  <li>HorzScrollBar</li>
  <li>ParentBackground</li>
  <li>Picture</li>
  <li>VertScrollBar</li>
  </ul>
  
  <p>I think it would be overkill to completely write a new component to do the behavior described above, that and I really wouldn't know where to begin. If this can be accomplished you could create some interesting components that are combined into one, but keep there original properties, methods and events etc.</p>
  
  <p>This is what I want to achieve here with a TImage inside a TScrollBox.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>The answer shown by Uwe Raabe works as expected. The TImage is now registered inside the TScrollBox, but appears as one component. The properties of the TImage are shown in the Object Inspector as Image. > which will reveal the properties of TImage :)</p>