0

I am trying to programmatically remove a selected component from its parent container using the code below (I may be using found incorrectly, but that is not the problem, suggestions are welcome):

void __fastcall TScrollControlsListContainer::RemoveItem(TWinControl* ctrl)
{
    // find control in vector containing TWinControl(s)
    std::vector<FWinControl*>::iterator found = std::find_if(FWinControls.begin(), FWinControls.end(), IsCtrl(ctrl));
    if(found != FWinControls.end())
    {
        Components->RemoveComponent(dynamic_cast<TComponent*>(found));
        //[bcc32 Error] ScrollControlsListContainer.cpp(208): E2193 Too few parameters in call to '_fastcall TComponent::GetComponent(int)' Full parser context
    
        FWinControls.erase(found);
    }
}

I am confused about the error, as only one parameter is required according to the help file example below:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    int I;
    TComponent *Temp;
    Memo1->Lines->Add("Components removed: ");
    Form2->Memo1->Lines->Add("Components added: ");
    for (I = ComponentCount - 1; I >= 0; I--)
    {
        Temp = Components[I];
        // Move only the components that are not controls.
        if (dynamic_cast<TControl *>(Temp) == NULL)
        {
            RemoveComponent(Temp);
            Memo1->Lines->Add(Temp->Name);
            Form2->InsertComponent(Temp);
            Form2->Memo1->Lines->Add(Temp->Name);
        }
    }
}

What am I missing here?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • The code you have shown cannot produce the error you have shown where indicated, as there is no call to `GetComponent()` there. Please show the "full context" that is provided. – Remy Lebeau Sep 06 '22 at 07:35
  • @Remy, yes I know there is no call to GetComponent(), that is what is confusing me, the the next line in the full context, from memory (as I am not near my system to get it right now) is the name of the method call with a single TWinControl parameter (ctrl) not a great deal more to give any clue (for me) to work out what is wrong. IsCtrl(ctrl) returns a FWinControl class object that holds the TWinControl as in return(item->ctrl==ctrl) I think also that I cannot use *found in this case, I would have to use the TWinControl that FWinControl object holds. I will post the full context in morning. –  Sep 06 '22 at 08:57

0 Answers0