title: TComboBox 'Control has no parent window' in destructor
body: <p>I'm using Delphi XE2.  I build a custom <code>TComboBox</code> so that I can easily add key/string pairs and handle the cleanup in the component's destructor.</p>
  
  <p><em>All</em> <code>if not (csDesigning in ComponentState)</code> <em>code is omitted for brevity.</em></p>
  
  <pre><code>interface
  
  type
    TKeyRec = class(TObject)
      Key: string;
      Value: string;
    end;
  
    TMyComboBox = class(TComboBox)
    public
      destructor Destroy; override;
      procedure AddItemPair(const Key, Value: string);
    end;
  
  implementation
  
  destructor TMyComboBox.Destroy;
  var i: Integer;
  begin
    for i := 0 to Self.Items.Count - 1 do
      Self.Items.Objects[i].Free;
    Self.Clear;
    inherited;
  end;
  
  procedure TMyComboBox.AddItemPair(const Key, Value: string);
  var rec: TKeyRec;
  begin
    rec := TKeyRec.Create;
    rec.Key := Key;
    rec.Value := Value;
    Self.Items.AddObject(Value, rec);
  end;
  </code></pre>
  
  <p>When the application closes, the destructor is called, but the <code>Items.Count</code> property is inaccessible because the <code>TComboBox</code> must have a parent control to access this property.  By the time the destructor is called, it no longer has a parent control.</p>
  
  <p>I saw this problem once before and had to store the objects in a separate <code>TList</code> and free them separately.  But that only worked because the order that I added them to the <code>TList</code> was always the same as the strings added to the combo box.  When the user selected a string, I could use the combo box index to find the correlating object in the <code>TList</code>.  If the combo box is sorted, then the indexes won't match, so I can't always use that solution.</p>
  
  <p>Has anyone else seen this?  How did you workaround the issue?  It would be really nice to be able to free the objects in the component's destructor!</p>