Solved

How to determin which component triggered an event?

Posted on 2002-04-05
3
187 Views
Last Modified: 2010-04-02
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
Comment
Question by:philtwo
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
thienpnguyen earned 300 total points
Comment Utility
void __fastcall TForm1::EntryDuplicate(TObject *Sender)
{
    // assume, you click on your TListBox
    TListBox *listbox = (TListBox *) Sender;
    listbox->Top = 10;
    //....

}
0
 
LVL 6

Expert Comment

by:thienpnguyen
Comment Utility
Other way,

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

}
0
 

Author Comment

by:philtwo
Comment Utility
Asbolute life saver - thanks alot!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now