472,796 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 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...

--
Mhsh Kumr. R

http://spaces.msn.com/members/cyberiafreak
Nov 17 '05 #1
3 9571
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...
--
Mhsh Kumr. 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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.