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
}
} 2 1630
Once a child window is closed it's disposed of. If you maintain a reference
to it it will just prevent the garbage collector from finalizing it.
If you want to re-show an MDI child window, or indeed any form, don't close
it, hide it
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
"Jon" <jh******@netze ro.net> wrote in message
news:0b******** *************** *****@phx.gbl.. . 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 }
}
Just thinking out loud here...
Trap the closing event.hide the window and cancel the close.
Hmm that might have implications for when you really want to close.
--
Bob Powell [MVP]
C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
"Jon" <jh******@netze ro.net> wrote in message
news:09******** *************** *****@phx.gbl.. . Bob,
Thanks for your input, but how can I prevent the user from closing the window?
Thanks again for your help.
Jon
-----Original Message----- Once a child window is closed it's disposed of. If you maintain a referenceto it it will just prevent the garbage collector from finalizing it. If you want to re-show an MDI child window, or indeed any
form, don't closeit, hide it
-- Bob Powell [MVP] C#, System.Drawing
September's edition of Well Formed is now available. http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm "Jon" <jh******@netze ro.net> wrote in message news:0b******* *************** ******@phx.gbl. .. 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 }
}
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
After following Microsofts admonition to reformat my system before doing a
final compilation of my app I got many warnings/errors upon compiling an rtf
file created in word. I used the Help Workshop program: hcw.exe that's
included with Visual Basic. This exact same file compiled perfectly with no
notes, warnings or errors prior to reformatting my system. Prior to the
reformatting, I copied the help.rtf file onto a CD and checked the box to...
|
by: Helmut Jarausch |
last post by:
Hi,
entering
help('rstrip')
or
help('ljust')
into IDLE's shell window I only get
no Python documentation found ...
|
by: Sarir Khamsi |
last post by:
Is there a way to get help the way you get it from the Python
interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the
module cmd.Cmd? I know how to add commands and help text to cmd.Cmd
but I would also like to get the man-page-like help for classes and
functions. Does anyone know how to do that? Thanks.
Sarir
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
<<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>>
<html>
|
by: Colin J. Williams |
last post by:
Python advertises some basic service:
C:\Python24>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
With numarray, help gives unhelpful responses:
| |
by: Tim Marshall |
last post by:
I'm putting together my first help file (using Easy Help,
http://www.easyhelp.com/). So far, so good. I'm able to use the Help
File and Help Context ID to have things from my help file pop up when F1
is pressed.
But how do I do this when my Access App screen is empty? A hidden form?
Also, how do I have a menu item that pulls up the help file? When I
open the help file on its own, there is a contents item tht appears, I'd
like to...
|
by: stuart_white_ |
last post by:
I've just upgraded from Python 2.3.3 to Python 2.4.2, and, although the
new version of Python seems to be running correctly, I can't seem
access the help from the interpreter.
On Python 2.3.3
---------------
Python 2.3.3 (#51, Dec 18 2003, 20:22:39)
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
|
by: JJ |
last post by:
Do you all use HTML help workshop to create your help system. I am finding
it quite clumsy to use. Mayeb because I am not used to using it.
Do any of you use any other techniques to create help for your progs? Whats
the current popular approach to creating help?
I am only wanting a straight help file accessible from a menu - no context
sensitive stuff.
TIA
|
by: trunxnirvana007 |
last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
|
by: PaulS |
last post by:
new to Fedora7, typed python in interactive interpreter, then help(). Then
modules to get a list of modules. Then module name to get info on a module
but no help file. What is the help file name? Is there an environmental
variable I have to set? Thanks,
Paul
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |