[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How to determin which component triggered an event?

I am working on my first windows project in Borland C++ and I can't seem to figure this out:

I need to have an array of components, or some way of quickly stepping through each one so I can duplicate the values, I chose an array.

I define my componenets:

TCheckBox ListBox[MAX_ITEMS];
 
for (count=0;count<MAX_ITEMS;count++) {
     ListBox[count] = new TCheckBox(this);
     ListBox[count].Top = 35;
     ListBox[count].Tag = count;
     // other properties and stuff ...
     ListBox[count].OnClick = &EntryDuplicate;
}

My question is how can I access the properties of the
TCheckBox componenet that triggered the event from the event?

Thanks in advance.
0
philtwo
Asked:
philtwo
  • 2
1 Solution
 
thienpnguyenCommented:
void __fastcall TForm1::EntryDuplicate(TObject *Sender)
{
    // assume, you click on your TListBox
    TListBox *listbox = (TListBox *) Sender;
    listbox->Top = 10;
    //....

}
0
 
thienpnguyenCommented:
Other way,

void __fastcall TForm1::EntryDuplicate(TObject *Sender)
{
   TListBox *listbox = dynamic_cast<TListBox*>( Sender );
   if( listbox != NULL )
   {
       listbox->Top = 10;
        //....
   }

}
0
 
philtwoAuthor Commented:
Asbolute life saver - thanks alot!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now