473,756 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2693
You must cast this->MdiParent to the MdiParent form class (FormMain)
--
Un saludo
Rodrigo Corral Gonzalez [MVP]

FAQ de microsoft.publi c.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.publi c.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
490
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 to parent container control as the child is created by an intermediary class that doesnt keep parent's handle or reference. regards, anony
25
6209
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 rarely refer to a subform ir parent form's controls or records from the other form. Instead, I call a procedure in that form that does the job. That's all fine and good, and nothing at all revolutionary, but it leaves one with an annoying...
13
7409
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 created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
3
13722
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 set them as
12
27882
by: Tom W | last post by:
What's the difference in these three?
4
3639
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 possible.. for example..i hav a menu in the parent form named "Administrator" whic has an item "mnuLogIn"..now when i click on login..another child form named "frmLogIn" is displayed..what i want to happen is this: when login form(frmLogIn) is...
7
2266
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 rebuild and all is well. The problem arises when I have the PasswordChar set, and then try to set Localizable to True for the UC. If I set Localizable to true and have PasswordChar set and rebuild, Visual Studio 2005 will then try to reload the...
1
1634
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 name of the main form and its child form. I have the handle of both the parent and child form(using FindWindow). Plz help me out.
0
1436
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 node. When I close the form, it will not be closed but minimised to the system tray. A double-click on the notify icon wakes it up and displays it again. My expection was that the treeview handle would be destroyed when the form is sent to the...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.