View Single Post
  #5   Spotlight this post!  
Unread 19-12-2006, 22:14
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Visual C++ 2005 Designer

Quote:
Originally Posted by 6600gt View Post
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.