Quote:
Originally Posted by 6600gt
Any other suggestions?
|
I think what you are trying to do is call a method that is a member of the Parent class from a MDI child form of class Child. If that is not what you are trying to do then disregard the rest of this post, and I'm confused.
If you are trying call a method that is on the MDI parent form, then this has nothing to do with inheritance, other than that both classes must inherit from the System.Windows.Forms.Form class. Note that the Form class has a property called
MdiParent that is a reference to the instance of the Form that is the MDI container. Now, to access methods that are members of the MDI parent, you have to cast that property as whatever class it really is. From what you posted, it would be:
Code:
Parent^ myParent = dynamic_cast<Parent^>(this->MdiParent);
From there you can call methods normally:
Code:
myParent->SomeMethod();
You do not use gcnew in this case because you don't want to create a new instance of the Parent class, you just need to use the reference and cast it correctly.