title: Class Reference as Property
body: <p>Google is useless for these sorts of searches, because you get hundreds of millions of results absolutely none of which relate to the specific question.</p>
  
  <p>The question is simply this:</p>
  
  <ul>
  <li>Is it possible to have a Class Reference Property in Delphi?</li>
  <li>If so, how?</li>
  </ul>
  
  <p>Here's what I've tried...</p>
  
  <pre><code>type
  
    TMyObject = class
      // ...
    end;
  
    TMyObjectClass = class of TMyObject
  
    TMyObjectA = class(TMyObject)
      // specifics here
    end;
  
    TMyObjectB  =class(TMyObject)
      // specifics here
    end;
  
    TMyComponent = class(TComponent)
    private
      FObjectType: TMyObjectClass;
    published
      property ObjectType: TMyObjectClass read FObjectType write FObjectType;
    end;
  </code></pre>
  
  <p>The above code compiles fine, however the Object Inspector does not show the <code>ObjectType</code> property at all.</p>
  
  <p>My objective here (if you haven't already guessed) is to make it so that I can select a class descendant from a specific base class, to make the same component behave in a different way.</p>
  
  <p>I want to do it this way so that the component doesn't need to know about the sub-classes directly (<em>it needs to be fully modular</em>).</p>
  
  <p>Let me just make this bit clear: <strong>I cannot use an Enum to choose between the sub-class types as the component cannot directly link to the sub-class types</strong> (<em>It's simply not possible in this particular case</em>)</p>
  
  <p>Anyway... thanks in advance!</p>