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

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 1329

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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.