Not only you need to include combo box types, but also the types derived from it, or, more likely, from
StdCtrls.TCustomComboBox
or, say,
StdCtrls.TCustomCombo
:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/StdCtrls_TComboBox.html[
^].
In all cases, you have to check up the instance of your type with operator
is
if myControl is StdCtrls.TCustomComboBox then
As the deletion is condition, you cannot work with index 0, so you will need to modify your cycle. Appropriate way it to traverse the list of controls in (important!) reverse order. Also, you may need to apply the recursive traversing of the controls.
Note that this is the operation based on
dynamic cast approach, where you have to examine the
runtime type
of the object known by its
compile-type type. Not only this can be a bit costly for the performance, it is also considered as violation of general OOP principles. Nevertheless, there are cases when you need to do that.
—SA