Board index » delphi » TCustomComboBox and Remove Objects

TCustomComboBox and Remove Objects

Hi,

I have built a customCombobox which is functionally similar to the standard
combobox.

I override the destructor and place code in there to remove all my objects (in
another procedure), the problem is that when I
call the RemoveObjects procedure in it I have the following line :

If Items.Count > 0 Then
  Begin
    ...
  End;

Delphi bombs out on the Items.Count Line with the error message that the
combobox has no parent window????

This only happens when I close down the executable project, but if I have a
button on the form which calls the Free method, then all works fine.

I have tried everything without any luck.

Has anyone solved this problem.

ATH
Louis

--
------------------------------------------------------------------------------
Louis Rogers                      | The views expressed are mine alone
Old Mutual                        | and not those of Old Mutual
Email: lrog...@oldmutual.com      |
------------------------------------------------------------------------------

 

Re:TCustomComboBox and Remove Objects


Louis Rogers wrote in a message to All:

LR> I have built a customCombobox which is functionally similar to the
LR> standard combobox.

LR> I override the destructor and place code in there to remove all my
LR> objects (in  another procedure), the problem is that when I
LR> call the RemoveObjects procedure in it I have the following line :

LR> If Items.Count > 0 Then
LR>   Begin
LR>     ...
LR>   End;

LR> Delphi bombs out on the Items.Count Line with the error message that
LR> the  combobox has no parent window????

A destructor is one of the few places where you should avoid calling the
'inherited' method as long as possible, placing it right at the end if at all
possible. Once the inherited destructor is done, the window containing the
combobox is destroyed, and there is no way to get at the items anymore. Hope
this helps!

Best regards,
   Christian // ctib...@silver.ct.se

.. User - a technical term used by computer pros. See idiot.

Other Threads