473,399 Members | 3,302 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,399 software developers and data experts.

Closing a child form in an MDI application - Problem

Hello,

In my MDI application when a new child window is opened I perform some
inital processing in the form load event of the child form. If an exception
is thrown I want to close down the form, however I am getting the following
error when I try and do this from the child form.
"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.windows.forms.dll"

"Additional information: Cannot call Close() while doing CreateHandle()."
+++++++++++++++++++++++++++++
SAMPLE CODE BELOW
+++++++++++++++++++++++++++++
private: System::Void frmDisplay_Load(System::Object * sender,
System::EventArgs * e)
{

try
{
//Perform processing
}

catch (Exception* e)
{
MessageBox::Show("Error");
this->Close();
}

}//end frm_load
Nov 17 '05 #1
2 1194
I have a question for you!
Do you know how to program in Native Windows Code?

"Ling Woo" wrote:
Hello,

In my MDI application when a new child window is opened I perform some
inital processing in the form load event of the child form. If an exception
is thrown I want to close down the form, however I am getting the following
error when I try and do this from the child form.
"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.windows.forms.dll"

"Additional information: Cannot call Close() while doing CreateHandle()."
+++++++++++++++++++++++++++++
SAMPLE CODE BELOW
+++++++++++++++++++++++++++++
private: System::Void frmDisplay_Load(System::Object * sender,
System::EventArgs * e)
{

try
{
//Perform processing
}

catch (Exception* e)
{
MessageBox::Show("Error");
this->Close();
}

}//end frm_load

Nov 17 '05 #2
No I don't . Why do you ask?
"David S. Hall" <ha********@sbcglobal.net> wrote in message
news:AC**********************************@microsof t.com...
I have a question for you!
Do you know how to program in Native Windows Code?

"Ling Woo" wrote:
Hello,

In my MDI application when a new child window is opened I perform some
inital processing in the form load event of the child form. If an
exception
is thrown I want to close down the form, however I am getting the
following
error when I try and do this from the child form.
"An unhandled exception of type 'System.InvalidOperationException'
occurred
in system.windows.forms.dll"

"Additional information: Cannot call Close() while doing CreateHandle()."
+++++++++++++++++++++++++++++
SAMPLE CODE BELOW
+++++++++++++++++++++++++++++
private: System::Void frmDisplay_Load(System::Object * sender,
System::EventArgs * e)
{

try
{
//Perform processing
}

catch (Exception* e)
{
MessageBox::Show("Error");
this->Close();
}

}//end frm_load

Nov 17 '05 #3

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

Similar topics

5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
2
by: chris in grimsby | last post by:
MDIChild Window Closing event not raised when MDI Parent is in a class library! Intructions to recreate problem: 1. Create a ClassLibrary project 2. Add an MDIParent form and a form that will...
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...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
3
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
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
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...
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
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...
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,...

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.