Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to determin which component triggered an event?

Posted on 2002-04-05
3
Medium Priority
?
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
thienpnguyen earned 1200 total points
ID: 6921443
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
ID: 6921461
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
ID: 6921921
Asbolute life saver - thanks alot!!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

610 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