Re: 'status' form and disposal problem

John Brett <[email protected]> Tue, 31 Jul 2007 15:29:19 +0100
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
On 31/07/07, Peter Osucha <[email protected]> wrote:
> I am showing a small form 'TimePanel' (which is a FixedToolWindow) as a
> TopMost window in response to a double-click on a status bar panel of my
> main app form (MainAppForm).  The form containing the status bar holds a
> class level variable '_timePanel' referencing the TimePanel form.
>
> In the constructor for MainAppForm, I instantiate the _timePanel object
> - but I don't show it.  If the user double clicks on the appropriate
> status bar panel, I check to make sure the _timePanel reference isn't
> null and then I call _timePanel.Show() to show the form.
>
> The problem... if the user closes the _timePanel form, and then double
> clicks on the status bar panel, an error can occur because the
> _timePanel variable is being disposed.
>
> How should I be creating this functionality so that this error doesn't
> occur?

Override the OnClosing method of the timePanel, cancel the close and hide
the form instead.

John

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com