Is it possible to create a set of components with different types?



  • The question is: Is it possible to create a range of components of different types?

    It is very often necessary to do the same for many cults, for example, to change a certain characteristic:

    TButton *a[]={Button1,Button2,Button3};
    for (int i=0;i<sizeof(a)/sizeof(a[0]);i++)
       a[i]->Enabled=true;
    

    What if the components are different, but have some similar properties that need to be changed? Is that possible?



  • Separate "one properties" into two groups.

    First group, she's mostly in a normal code. Single properties are defined not in each component but in an ancestor. It's enough to find a suitable ancestor, and the task is very simple. For TButton, we see the list TObject - TPersistent - state TComponent - TControl - TWinControl - tie - - TButtonControl - Tar TButton. I suspect you'll find TWinControl. I mean, if you create a TWinControl, you can add TButton, TEdit and others.

    The other group is when the properties are even the same, but they are declared on their own. It's not that simple, there are different methods.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2