473,587 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ 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.Regist erDocumentView( 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
PunchDocumentVi ew view = new PunchDocumentVi ew();
view.Show();
Application.Run ();

public void RegisterDocumen tView (frmChild view)
{
Documents.Add(v iew);
}
}

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

private void menuWindow_Popu p(object sender,
System.EventArg s e)
{
menuWindow.Menu Items.Clear();
int ordinal = 1;
foreach (frmChild view in
DocumentManager .Current.Docume nts)
{
WindowMenuItem item = new WindowMenuItem( );
menuWindow.Menu items.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 1348

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

Similar topics

3
3264
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 from a child class, the method uses the parent class for scope (not the originating child class). For example, see the following block of code: ...
1
4556
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 = totalNumWindowsCreated + 1; childWnds.push(window.open(link, "child" +
2
3802
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 AddItem2DropDown(item){ exists = false; for(d=0;d<drpDwn.length;d++){ if(drpDwn.options.value == item.value)
0
277
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" 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...
4
2017
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 identifying from the lParam or wParam whether the message came from a child window or the parent? And what if the message uses some other data in the wParam or...
1
11557
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 http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all...
1
1558
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 Function.prototype.apply() function to call a function that is passed as parameter. The problem is: It works as long as the functions that are being passed...
1
25646
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 bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that...
4
3970
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 the first child window closes after opening the second child. This is the second time I am typing the post, I lost all content because the site...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.