473,473 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Scope of Child Window in MDI app

Jon
I am writing an MDI app that uses a document manager class
to keep track of opened child windows. I want the user to
be able to close a child window, but then re-open the
window from the "Window" menu if they want.

What happens to the child window after it is closed? Even
though my document manager maintains the instance of the
child and displays the name in the menu, when I try to use
the show() method or the activate() method on a closed
child, nothing happens.

Can anyone help me with this?

Some of the code is below:

In the load event handler for the child, I register the
child with the following code-

DocumentManager.Current.RegisterDocumentView(this) ;
Here is the DocumentManager Class:

public class DocumentManager
{
public DocumentManager()
{}

private static DocumentManager current;
private ArrayList documents = new ArrayList();

public static DocumentManager Current
{get{return current;}}
public ArrayList Documents
{get{return documents;}}

[STAThread()] static void Main()
{
current = new DocumentManager();
///instantiate the parent window
PunchDocumentView view = new PunchDocumentView();
view.Show();
Application.Run();

public void RegisterDocumentView (frmChild view)
{
Documents.Add(view);
}
}

The popup event handler for the parent window creates the
menu with all documents currently in the manager:

private void menuWindow_Popup(object sender,
System.EventArgs e)
{
menuWindow.MenuItems.Clear();
int ordinal = 1;
foreach (frmChild view in
DocumentManager.Current.Documents)
{
WindowMenuItem item = new WindowMenuItem();
menuWindow.Menuitems.Add(item);
ordinal++;

And finally the WindowMenuItem class constructs the items
to be displayed in the menu. The overridden OnClick event
handler is where I am trying to display the closed form,
but it isn't working:

public class WindowMenuItem : System.Windows.Forms.MenuItem
{
public frmChild View;

public WindowMenuItem(int index, frmChild view)
{
View = view;
Text = string.Format("{0}{1}", index, View.Text)
}

protected override void OnClick(System.EventArgs e)
{
View.Show(); ///These 2 methods don't appear
View.Activate(); ///to do anything if the child
///is closed
}

}

Nov 15 '05 #1
0 1333

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

Similar topics

3
by: wwight | last post by:
As many people have noticed by now, PHP exhibits some frustrating behavior when it comes to static fields and methods. For instance, when a static method is defined in a parent class, but called...
1
by: ian.michel | last post by:
I have a parent window that pushes a new window object onto an Array with the following code : OpenChild() { //totalNumWindowsCreated is global totalNumWindowsCreated =...
2
by: Bostonasian | last post by:
I am trying to append options to dropdown in parent window from option items in child window. In parent window, I have following code: <script language="javascript"> function...
0
by: Jon | last post by:
I am writing an MDI app that uses a document manager class to keep track of opened child windows. I want the user to be able to close a child window, but then re-open the window from the "Window"...
4
by: Bonj | last post by:
Further to my last post, I have managed to get a child window to display. But its messages are routed to the same WNDPROC that the main window's messages are routed to - what is the way of...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
1
by: Arnaud Diederen | last post by:
Hello everyone, I have a little problem with IE6. Imagine I have a webapp that has a main/root/parent window, in which there is a function (called: executor()) that makes use of the...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
4
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.