473,387 Members | 3,820 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,387 software developers and data experts.

MDI parent and child communication...??

Hi groups,
How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT.

Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI parent menu functions. if i select draw line in MDI parent, the line should be drawn in current active child..any URLS for this or guide me to achieve this communication...

--
Mähésh Kumär. R

http://spaces.msn.com/members/cyberiafreak
Nov 17 '05 #1
3 9658
Hi

Are the child forms all of the same type, or are they of different types

Kind regards

Ronnie

"Maheshkumar.R" wrote:
Hi groups,
How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT.

Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI parent menu functions. if i select draw line in MDI parent, the line should be drawn in current active child..any URLS for this or guide me to achieve this communication...

--
Mähésh Kumär. R

http://spaces.msn.com/members/cyberiafreak

Nov 17 '05 #2
All forms are same type....loaded with an activeX component in that child
form.
let me give my scenario, thru MDI parent i 'm selectin 3 raw images from the
File_open dialog of MDIParent. For displaying this images I'm creating
objects of a child form with activex defined in it.

so my mdichild component should recieve the filename from MDI parent and
also i want to play with that MDichild(loaded with activex) from the menu;s
provided in MDI parent form..
MDI parent ->>> events, functions ---->> MDI child (which is active)
How i can communicate this form...?

Thnks for your reply...

Mahes


"Ronnie Edgar" <Ro*********@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Hi

Are the child forms all of the same type, or are they of different types

Kind regards

Ronnie

"Maheshkumar.R" wrote:
Hi groups,
How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT.
Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI parent menu functions. if i select draw line in MDI
parent, the line should be drawn in current active child..any URLS for this
or guide me to achieve this communication...
--
Mähésh Kumär. R

http://spaces.msn.com/members/cyberiafreak

Nov 17 '05 #3
Hi

I will supply some sample code...

create a test app, with two forms, and cut and paste the following code into
the forms replacing all of the existing code..

what is illustrated is that a parent carries a reference to its active
child, and the child carries a reference to its parent, therefore when that
form becomes active the parents active child can be set.

Form1

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MDI_Test
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "Say Hello";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 406);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;

private Form2 m_fCurrent;

public Form2 fCurrent
{
get
{
return m_fCurrent;
}
set
{
m_fCurrent = value;
}
}

private void Form1_Load(object sender, System.EventArgs e)
{
Form2 f2 = new Form2();

f2.MdiParent = this;
f2.Show();
f2.f1 = this;
f2.Text = "Bill";

Form2 f3 = new Form2();

f3.MdiParent = this;
f3.Show();
f3.f1 = this;
f3.Text = "Mary";
}

private void menuItem1_Click(object sender, System.EventArgs e)
{
fCurrent.SayHello();
}
}
}
Form 2

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MDI_Test
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form2()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.Enter += new System.EventHandler(this.Form2_Enter);

}
#endregion

private Form1 m_f1;

public Form1 f1
{
get
{
return m_f1;
}
set
{
m_f1 = value;
}
}
private void Form2_Load(object sender, System.EventArgs e)
{

}

private void Form2_Enter(object sender, System.EventArgs e)
{
this.f1.fCurrent = this;
this.f1.Text = this.f1.fCurrent.Text;
}

public void SayHello()
{
MessageBox.Show("Hello I am a - " + this.Name + " My Name Is " +
this.Text);
}
}
}
//end of code

what this demonstrates is the creation of two forms of the same type, and
calling the method sayhello() on the active form.

remember and switch the active forms before trying the menu option, or there
is no active child set...


"Maheshkumar.R" wrote:
All forms are same type....loaded with an activeX component in that child
form.
let me give my scenario, thru MDI parent i 'm selectin 3 raw images from the
File_open dialog of MDIParent. For displaying this images I'm creating
objects of a child form with activex defined in it.

so my mdichild component should recieve the filename from MDI parent and
also i want to play with that MDichild(loaded with activex) from the menu;s
provided in MDI parent form..
MDI parent ->>> events, functions ---->> MDI child (which is active)
How i can communicate this form...?

Thnks for your reply...

Mahes


"Ronnie Edgar" <Ro*********@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
Hi

Are the child forms all of the same type, or are they of different types

Kind regards

Ronnie

"Maheshkumar.R" wrote:
Hi groups,
How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT.
Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI parent menu functions. if i select draw line in MDI
parent, the line should be drawn in current active child..any URLS for this
or guide me to achieve this communication...
--
Mähésh Kumär. R

http://spaces.msn.com/members/cyberiafreak


Nov 17 '05 #4

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

Similar topics

5
by: Paul | last post by:
Hi all, Here is what I am trying to do. I have a parent class calling a child class. when one function in child class is called, i need to call parent class' function. How can I get parent class'...
1
by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 ...
3
by: Lumpierbritches | last post by:
Thank you in advance for all your assistance, it is GREATLY appreciated. I'm writing a small Access 2000 program for tracking Kennel Litters for a friend and I'm wondering how I can loop through...
4
by: Danny Tuppeny | last post by:
Hi all, I've been trying to write some classes, so when I have a parent-child relationship, such as with Folders in my application, I don't have to remember to add a parent reference, as well as...
5
by: Jim | last post by:
I have a user control that has two nested user controls within it. I have a method in the parent called CloseDetailsMaint, and I need to be able to call it from one of the child user controls that...
2
by: Jim Shank | last post by:
I am really trying to find the best OOP way of doing this. I have a parent MDI form with multiple children and I am trying to communicate variables between them. I have been able to successfully...
2
by: epaetz | last post by:
Is there a way to decouple the linkage between a parent and a child window? Does the parent window have any sort of a collection that holds all the children that it has spawned? I want to...
1
by: Sebouh | last post by:
Hello guys. This time, i need to implement waitpid in order to know if one of the children of a parent has finished executing. The assignment requires me to run a limited number of child processes....
0
by: uupi_duu | last post by:
Hello, I have a parent class which creates and uses child class. Child class use it's own methods for different tasks. If an error occurs in child classes methods I would like to inform it to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.