Form close ('X' button) not working

  • Thread starter Thread starter Colin Young
  • Start date Start date
C

Colin Young

I have a form that I dynamically instantiate user controls on. I also
dynamically remove use controls. Frequently the application just won't end
when I click the close button on the main form. The Close event is being
called and I am making sure that I set the focus to a control that is not
being removed before I remove any user controls. I thought that had fixed
the problem, but it has reappeared..

Any suggestions? I've attached the relevant code to the end of this message.

Thanks.

Colin

private void LoadPlugin(IGBPlugIn plugIn)
{
ModuleToolBar.Focus();
MainControlPanel.Controls.Clear();
ModuleActionsPanel.Controls.Clear();

plugIn.MainControl.Dock = DockStyle.Fill;
MainControlPanel.Controls.Add(plugIn.MainControl);

foreach (object o in plugIn.PanelControls)
{
XPanderControl.XPander panel = new XPanderControl.XPander();
panel.DockPadding.Left = 4;
panel.DockPadding.Right = 4;
panel.DockPadding.Bottom = 4;
((PanelControl)o).Control.Dock = DockStyle.Fill;
panel.Controls.Add(((PanelControl)o).Control);
panel.CaptionText = ((PanelControl)o).Caption;
ModuleActionsPanel.Controls.Add(panel);
}
}

private void GBWPipelineOfferMenu_Click(object sender, System.EventArgs e)
{
IGBPlugIn GBWOffers = new
GordonBrothers.GBW.DealsheetManager.Controls.OfferSheetControl();
LoadPlugin(GBWOffers);
}

private void GBWPipelineDealsheetMenu_Click(object sender, System.EventArgs
e)
{
IGBPlugIn GBWDeals = new
GordonBrothers.GBW.DealsheetManager.Controls.DealSheetControl();
LoadPlugin(GBWDeals);
}
 
* "Colin Young said:
I have a form that I dynamically instantiate user controls on. I also
dynamically remove use controls. Frequently the application just won't end
when I click the close button on the main form. The Close event is being
called and I am making sure that I set the focus to a control that is not
being removed before I remove any user controls. I thought that had fixed
the problem, but it has reappeared..

Maybe the famous "form close bug"?

C# code to repro the close bug:

<URL:http://www.jelovic.com/binaries/WindowsFormsCloseBugDemo.zip>

Some information on the bug:

<URL:http://www.google.de/[email protected]>

Fixed in .NET 1.1.
 
Herfried K. Wagner said:
Maybe the famous "form close bug"?

C# code to repro the close bug:

<URL:http://www.jelovic.com/binaries/WindowsFormsCloseBugDemo.zip>

Some information on the bug:

<URL:http://www.google.de/[email protected]
ncis.de>

Fixed in .NET 1.1.


Btw i have a consistency question. All .NET programs written with VS 2002
run without modification in .net framework 1.1? All programs written with VS
2003 will run without any modification in 2.0? Also in Windows Update only
the latest .NET is available and upcoming OS will only have the
latest-at-their-time .NET available (e.g. Windows 2003 server family).

If they will not run then, soon the picture will become very messy.






Ioannis Vranos
 
Hi,

I have had the same problem. I tried the suggestions that I found on various
newsgroups, but I haven't managed to get them to work.

I believe this bug has been fixed in the 1.1 version, so if you can, upgrade
to Visual Studio 2003.

Chris
 
----- Ioannis Vranos wrote: ----
All .NET programs written with VS 2002 run without modification in .net framework 1.1?
All programs written with VS 2003 will run without any modification in 2.0? Also in Window
Update only the latest .NET is available and upcoming OS will only have th
latest-at-their-time .NET available (e.g. Windows 2003 server family)

No. Microsoft has said that they will try to introduce as few breaking changes as is feasible, but they will not guarantee 100% backward compatibility when they release new versions of the framework. Multiple versions of the framework can exist on the same machine without conflict, however, so you can be sure your app runs as intended as long as the user has the version of the framework it was compiled against





Ioannis Vrano
 
Charlie Williams said:
No. Microsoft has said that they will try to introduce as few breaking
changes as is feasible, but they will not guarantee 100% backward
compatibility when they release new
versions of the framework. Multiple versions of the framework can exist
on the same machine without conflict, however, so you can be sure your app
runs as intended as long as
the user has the version of the framework it was compiled against.


That's nice but there is a flaw with this schema. At first we do not know if
our .net framework 1.x will install properly in windows 20xx, and the most
important of all is that MS must keep fixing all the existing .net
frameworks out there, whose number (and thus total difficulty) will keep
increasing. So if a new security hole is discovered, MS will have to issue
fixes for all the hundrends of .net frameworks it will have produced. If
they suggest "use only the latest framework", that would mean firstly that
all VS developers will have to upgrade to the latest VS or competing
products and secondly in reality all those apps and framework will remain
running around creating a security nightmare.

Hasn't really *anyone* thought these?






Regards,

Ioannis Vranos
 
Hi Colin,

I'm not sure if this problem is still caused by focus,
Will you still have this problem if you manually set focus to some other
control (e.g. a TextBox on the Form etc) which is not in the panel before
it clicking the button?

if the problem disappeared, I suspect it is still caused by the focus issue,
if not, it might be caused by some other issues. I need know more
information about this issue to assist you trouble shooting it further.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top