Can I get handle of parent MDI form?

E

Eddie

If FormMain = MDI parent, FormSub = Child parent,
I execute FormSub from the menu like this way.

FormSub^ sub = gcnew FormSub;
sub->MdiParent = this;
sub->Show();

This can generate child form sub in FormMain.
In th FormMain, there is status bar label named statusBar;
I'd like to add code in the sub form that can access statusBar of parent
form.

I thought I can access to parent form member function in the sub form
like this way,
(This worked in VB.NET)
this->MdiParent->statusBar->Text = "sub closed!!!";
But this->MdiParent doesn't show me statusBar.
this->ParentForm doesn't work, too.
I made status bar label public in the MainForm, it doesn't work, too.

Is there any other way I can try?

Thanks.
 
E

Eddie

Thanks for your answer Mr. Corral.

Here comes another problem.

in Parent.h

public ref class Parent : public System::Windows::Forms::Form {
public:
Parent {
...
}
....

in Project.cpp

#include "stdafx.h"
#include "Child.h"
#include "Parent.h"
....

in Child.h

public ref class Child: : public System::Windows::Forms::Form {
public:
Child {
...
}
....


When I add a function in Parent class like

Child^ child = gcnew Child;
child->MdiParent = this;
child->Show();

I can use the all the functions of the child.
But when I tried to use parent form in the Child class like

Form^ parent = gcnew Form;
parent = this->MdiParent; // This should be Parent
parent->statusBar->Text = "Test"; // Error, not visible

Ok, as your comment, this should be

Parent^ parent = gcnew Parent;
parent = this->MdiParent;
parent->statusBar->Text = "Test";

But I can't do this. T_T
When the include file sequence is
#include "Child.h"
#include "Parent.h"
class Child can't see class Parent so the compiler's complaining "What's
the Parent, men?"
After changing the sequence, "What's the Child, men?"

Thanks for your comment and plz help me one more time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top