You're welcome,
I'd like to suggest you to learn something about casting... it is an
essential practice in object oriented languages.
Take Care: using dynamic_cast<Type*>(Object) might return NULL (0) if the
cast failes....
that means if you cast some object to a type that it is not related too
it(inherited from).
If you are familiar with exception handling, you could use
try
{
TargetType* target = __try_cast<TargetType*>(source);
}
catch (InvalidCastException* ice)
{
//do some error handling
}
dynmic_cast returns NULL for invalid casts,
__try_cast throws an Exception.
Greets, Sebastian Dau
> It worked! With this operator I can get all the properties of the
> component that suffered the event. That's what I wanted. Thanks very
> much, really!
Marcelo - 01 Jun 2005 15:52 GMT
Thank you for the suggestion.
Could you help me in one more thing? I am working with 2 forms. For
exemple, here :
profileToMenu = new MenuItem(profileName);
profileToMenu->Click += new System::EventHandler(this,
&ConnectionPreferences::RunTimeItem_Click);
a menu item is created and related to the RunTimeItem_Click event od
the ConnectionPreferences class . Now, if I create a menuItem in
another Form, let us say "Form1" class, how would I relate the click of
this menu item (which is in Form1) to the same event RunTimeItem_Click
of the ConnectionPreferences Form?
menuInForm1 = new MenuItem(profileName);
menuInForm1 ->Click += new System::EventHandler(this */(???)*/,
&ConnectionPreferences::RunTimeItem_Click */(???)*/);
Greetings, Marcelo Schio
Sebastian Dau - 02 Jun 2005 13:26 GMT
> Thank you for the suggestion.
> Could you help me in one more thing? I am working with 2 forms. For
[quoted text clipped - 15 lines]
>
> Greetings, Marcelo Schio
Quick and dirty:
public __gc class Form2 : public Windows::Forms
{
//...
public: void Form1_MenuItem1_OnClick ( Object* sender , EventArgs* ea )
{
//react on event
}
};
public class Form1 : Windows::Forms
{
//...
void InitForm2 ( )
{
Form2* form2 = new Form2 ();
menuInForm1 = new MenuItem(profileName);
menuInForm1 ->Click += new System::EventHandler(form2 ,
&Form2::Form1_MenuItem1_OnClick );
}
};
This is the idea of it very straight forward, hopefully helpful.
Greets, Sebastian Dau
Marcelo - 03 Jun 2005 08:18 GMT
Thank you once more! It worked perfectly.