?
Solved

How to determin which component triggered an event?

Posted on 2002-04-05
3
Medium Priority
?
195 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…
Suggested Courses

800 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