MDI Parent and MDI child..

M

Maheshkumar.R

Hello groups,

I have few questions, please do assist me to solve this queries...

Assuming i'm using VS2005 beta 2, C#


q(1). I have MDI parent and MDI child window. I have placed tools menu in MDI parent which is containing a list of items say imagesharp, imagecontrast etc....if i click imagesharp of MDI parent, i have to sharp the image in MDI child. How i can communicate [ MDI Parent ---- > MDI child ] ??

q(2). Wht are all the ways to access the MDI child member functions from MDI parent class... ??

q(3). Using this.activechild to get the current active child window, but do know how to pass an event or variables from MDI parent to that current active child...???
 
B

Bob Powell [MVP]

In an MDI application the menu items in the child forms will merge with the menu items of the parent. Generally you should place options that pertain to all windows such as load a file, arrange windows and global application settings in the MDI parent's menu and the operations that pertain to the MDI children such as specific editing features etc, into the menu's of the MDI child classes.

As with all classes, to access them from the outside, a clearly defined interface is required. You can do one of two things to give yourself access to these interfaces. #1 create public properties and methods in the MDI child classes and then cast the reference that you obtain from the active MDI child property of the main form to that class. This will enable you to access individual class types and their properties. The disadvantage in this method will become apparent when you have more than one MDI child type. #2 create an interface implemented by all child types and cast any references to child windows to that interface. You can, for example, create an interface that runs commands using a string to identify the command name. This method is more robust when there are several types of MDI child and means that you can alsways assume that the child will implement the interface no matter what the underlying type of the child class.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Hello groups,

I have few questions, please do assist me to solve this queries...

Assuming i'm using VS2005 beta 2, C#


q(1). I have MDI parent and MDI child window. I have placed tools menu in MDI parent which is containing a list of items say imagesharp, imagecontrast etc....if i click imagesharp of MDI parent, i have to sharp the image in MDI child. How i can communicate [ MDI Parent ---- > MDI child ] ??

q(2). Wht are all the ways to access the MDI child member functions from MDI parent class... ??

q(3). Using this.activechild to get the current active child window, but do know how to pass an event or variables from MDI parent to that current active child...???
 
M

Maheshkumar.R

Thnkz Powell for your brief explanation. Yes i got it, started to go for interface mechanism as you suggested. I mean, I have defined an interface whose implementations are in MDI child. so i can do call those MDIchild easly using this way,

// IMDICbild is the interface name
IMDIChild child = this.ActiveMdiChild as IMDIChild;

This is working fine, THnkz for your reply,
Maheshkumar.R
http://spaces.msn.com/members/cyberiafreak

In an MDI application the menu items in the child forms will merge with the menu items of the parent. Generally you should place options that pertain to all windows such as load a file, arrange windows and global application settings in the MDI parent's menu and the operations that pertain to the MDI children such as specific editing features etc, into the menu's of the MDI child classes.

As with all classes, to access them from the outside, a clearly defined interface is required. You can do one of two things to give yourself access to these interfaces. #1 create public properties and methods in the MDI child classes and then cast the reference that you obtain from the active MDI child property of the main form to that class. This will enable you to access individual class types and their properties. The disadvantage in this method will become apparent when you have more than one MDI child type. #2 create an interface implemented by all child types and cast any references to child windows to that interface. You can, for example, create an interface that runs commands using a string to identify the command name. This method is more robust when there are several types of MDI child and means that you can alsways assume that the child will implement the interface no matter what the underlying type of the child class.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Hello groups,

I have few questions, please do assist me to solve this queries...

Assuming i'm using VS2005 beta 2, C#


q(1). I have MDI parent and MDI child window. I have placed tools menu in MDI parent which is containing a list of items say imagesharp, imagecontrast etc....if i click imagesharp of MDI parent, i have to sharp the image in MDI child. How i can communicate [ MDI Parent ---- > MDI child ] ??

q(2). Wht are all the ways to access the MDI child member functions from MDI parent class... ??

q(3). Using this.activechild to get the current active child window, but do know how to pass an event or variables from MDI parent to that current active child...???
 

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