Ten kod prezentuje usunięcie wszystkich komponentów należących do klasy Tbutton. Tworzmy wskaźnik do którego pętlą przypisujemy kolejne komponenty formy. Jeśli klasa komponentu jest równa z TButton to usuwamy komponent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void __fastcall TForm1::Button1Click(TObject *Sender) { TComponent *komponent; for (int i = ComponentCount - 1; i >= 0; i--) { komponent = Components; // przypisuje komopnent z formy if (AnsiString(komponent->ClassName()) == "TButton") delete komponent; } } |
Autor: Drazek