"Remy Lebeau [TeamB]" <gambi...@yahoo.com> wrote in message
news:3cdab063$1_1@dnews...
Quote
> "Matt Ross" <m._g._ross@_herts._ac._uk> wrote in message
> news:3cda715e$1_2@dnews...
> > Can I use the TObject *Sender parameter to do this?
> Sender is a pointer to the actual object that triggered the event, yes.
Oh good so I'm on the right track.
Quote
> > It doesn't work.
> Is the event handler actually assigned to a TFEISEdit instance?
> dynamic_cast will fail if Sender is not actually a TFEISEdit object.
> Also, you should always check the return value of dynamic_cast before
using
> the object, because dynamic_cast returns NULL if it fails:
> TFEISEdit *edit = dynamic_cast<TFEISEdit*>(Sender);
> if(edit)
> thisuser = (TNewUser *)UserList->Items[edit->Row];
Yes the event handler is assigned inside various object types (listed
below). Excellent, I was wondering how I could get it to tell what type it
was being called from.
Quote
> > Also I have done a dynamic_cast to the TFEISEdit class but not all
> > of the objects that use the function are of the same class. So I also
need
> > a way of typecasting it to the correct type.
> Then you either need to perform multiple casts until it finds one that
> works, or you need to derive your objects from a common base class that
you
> can then cast to instead (if they don't already).
> What other object types also use this function?
The full list is:
TFEISEdit (descended from TEdit)
TFEISCheckBox (descended from TCheckBox)
TFEISComboBox (descended from TComboBox)
TFEISCSpinEdit (descended from TCSpinEdit in the Samples tab)
TFEISSpeedButton (descended from TSpeedButton)
Each of these classes adds only 1 new property: int Row. I use this to
determine what row on the form they are on as each row represents
information on one new user. Each row includes: Username, Surname,
Forenames, Windows, Unix, Type (i.e. Staff or Student), Quota, Delete this
row button. An example of one of these class declarations follows:
class TFEISEdit : public TEdit
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
int Row;
virtual __fastcall TFEISEdit(TComponent* Owner);
What I've noticed is that if I use dynamic_cast like this:
dynamic_cast<TFEISEdit*>(Sender) (currently only to the TFEISEdit type but I
will change it) I get this kind of error:
'Unresolved external TFEISEdit:: referenced from........'
These classes are defined in the header file of the form that uses them.
What am I missing?
Thanks for your help. I was beginning to think I would have to re-work my
code to do this, now it looks like I'm close to a solution.
--
Matt Ross
Please remove all underscore characters from my e-mail address.