473,320 Members | 1,839 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,320 software developers and data experts.

Can an MDI child listen for mainmenu events on the MDI parent?

Tom
Rather than merge child menus, I would like for some common functionality
between various MDI child forms to process an event fired from the main
menu, depending on who is in focus.

Is this doable?
Nov 16 '05 #1
6 1880
Hi Tom,

"Tom" <nf*@nospam.com> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl...
Rather than merge child menus, I would like for some common functionality
between various MDI child forms to process an event fired from the main
menu, depending on who is in focus.

Is this doable?


It's doable, but I think it'd be unnecessarily complicated. I would
suggest that you factor the functionality driven by the menu into one or
more interfaces. Each MDI child form can implement the interface(s). In the
menu event handler in the MDI parent, get the interface from the active
child form and call the appropriate method.

Regards,
Daniel
Nov 16 '05 #2
Tom
This sounds reasonable. Do you have the syntax for how I would call down to
the active MDI child form to call its interface? Would this require a
delegate?

"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Tom,

"Tom" <nf*@nospam.com> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl...
Rather than merge child menus, I would like for some common functionality between various MDI child forms to process an event fired from the main
menu, depending on who is in focus.

Is this doable?
It's doable, but I think it'd be unnecessarily complicated. I would
suggest that you factor the functionality driven by the menu into one or
more interfaces. Each MDI child form can implement the interface(s). In

the menu event handler in the MDI parent, get the interface from the active
child form and call the appropriate method.

Regards,
Daniel

Nov 16 '05 #3
Hi Tom,

"Tom" <nf*@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This sounds reasonable. Do you have the syntax for how I would call down to the active MDI child form to call its interface? Would this require a
delegate?


In the event handler in the MDI parent form "cast" the ActiveMdiChild
property of the MDI parent form to the interface. Supposing the MDI child
forms implement an interface named ISomeInterface:

...
ISomeInterface someInterface = this.ActiveMdiChild as
ISomeInterface;

if (someInterface != null)
{
someInterface.DoStuff();
}
...

Regards,
Daniel
Nov 16 '05 #4
Daniel and Tom,

Instead of doing this, you can place a menu on your MDI child form.
When contained within an MDI parent, the parent will merge the child menu
with the main menu and will call the child menu's event handlers as well (I
believe).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:Oa****************@TK2MSFTNGP11.phx.gbl...
Hi Tom,

"Tom" <nf*@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This sounds reasonable. Do you have the syntax for how I would call down

to
the active MDI child form to call its interface? Would this require a
delegate?


In the event handler in the MDI parent form "cast" the ActiveMdiChild
property of the MDI parent form to the interface. Supposing the MDI child
forms implement an interface named ISomeInterface:

...
ISomeInterface someInterface = this.ActiveMdiChild as
ISomeInterface;

if (someInterface != null)
{
someInterface.DoStuff();
}
...

Regards,
Daniel

Nov 16 '05 #5
Hi Nicholas,

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Daniel and Tom,

Instead of doing this, you can place a menu on your MDI child form.
When contained within an MDI parent, the parent will merge the child menu
with the main menu and will call the child menu's event handlers as well (I believe).

Hope this helps.


You are 100% correct, as usual, but I will say that for our project this
wouldn't have worked as well. We have a global toolbar as well as menu items
and they are standard for every child form. I've also found it a challenge
to get the menu items to merge the way I expect (i.e. I don't want two Edit
menus, rather I want to merge the Edit menus).

Regards,
Daniel
Nov 16 '05 #6
Tom
"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Nicholas,

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Daniel and Tom,

Instead of doing this, you can place a menu on your MDI child form.
When contained within an MDI parent, the parent will merge the child menu with the main menu and will call the child menu's event handlers as well (I
believe).

Hope this helps.


You are 100% correct, as usual, but I will say that for our project

this wouldn't have worked as well. We have a global toolbar as well as menu items and they are standard for every child form. I've also found it a challenge
to get the menu items to merge the way I expect (i.e. I don't want two Edit menus, rather I want to merge the Edit menus).

Regards,
Daniel


I am facing the same design pattern vis-a-vis a global toolbar and agree
that your solution may be more appropriate in this scenario. I have also
found that the merge is sometimes difficult to get right.

Thanks for the tip... it appears to be exactly what I was hoping for.
Nov 16 '05 #7

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

Similar topics

3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
4
by: Sean Connery | last post by:
I know I can merge a child forms menu into the MDI parent's mainmenu, but I would also like to listen for common events fired from the mainmenu that might be of interest to any child forms. Is...
3
by: PK | last post by:
Hi, I've a MDI form and a child form that comes from a dll. Everything works fine until I had to uncheck or check a menu item in the MDI form based on the changes in the child form. How to acheive...
2
by: Jim H | last post by:
I would like to have some MenuItems that are specific to my child form appear in the main menu. In the MSDN documentation: Menu merging is typically done to merge the menus of a Multiple...
3
by: Maheshkumar.R | last post by:
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...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: Steve Barnett | last post by:
I've created a simple MDI application and have designated the Window menu to keep track of the mdi children. When I first load an mdi child, it's caption consists of "File: no file loaded" and this...
4
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

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.