473,231 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Can I get handle of parent MDI form?

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.

Dec 14 '05 #1
3 2643
You must cast this->MdiParent to the MdiParent form class (FormMain)
--
Un saludo
Rodrigo Corral Gonzalez [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
Dec 14 '05 #2
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.

Rodrigo Corral [MVP] wrote:
You must cast this->MdiParent to the MdiParent form class (FormMain)

Dec 15 '05 #3
You must do a forward class declaration.

http://www-subatech.in2p3.fr/~photon...PP-INC-1.shtml

You don˘Ąt need do:

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

Better:

Parent^ parent = this->MdiParent;
parent->statusBar->Text = "Test";
--
Un saludo
Rodrigo Corral Gonzalez [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org


Dec 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ayaz Ali | last post by:
Hello, Does anybody know how to get window handle of parent window (the main application window) in C#. I am trying to set mdiParent of a child window in child's Load( ). I dont know how to set it...
25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
3
by: TC | last post by:
Hey Folks, I am using the following 4 Win32 APIs with a C# AddIn: FindWindow SetWindowLong SetForegroundWindow EnableWindow Within the AddIn, there are some winforms. I use these APIs to...
12
by: Tom W | last post by:
What's the difference in these three?
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
7
by: Ryan | last post by:
I'm creating a user control that has a handful of controls on it (19 in total). One of the controls on the UC is a textbox for a user's password, so I've set the PasswordChar property to "*". I...
1
by: Gurur | last post by:
I want to access the properties of a child form of an application from another application. Properties means I want to perform some action on the visibility of the child form. I have the class...
0
by: Marc Bartsch | last post by:
Hi, I have a WinForms application (C#, VS 2005) that consists of a treeview control and a notify icon. Below is a complete example of this application. The treeview has one root node and one child...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.