Thanks mike, I'll give this a try and see if it works.

On Fri, 2012-01-13 at 15:07 +0200, Mike Fry wrote:
> On 2012/01/13 05:20, Jeff wrote:
> 
> > I'm having a minor problem with my program.  If the user has minimized
> > the main window, and for whatever reason the OS does an automatic
> > reboot, then when the ini file that is written with all of the forms
> > settings including the position and size, the top and left variables are
> > written at -32000.  When the user starts the program after the reboot,
> > the form is position off the desktop.
> >
> > Prior to writing the form settings in the FormClosing Event, I test if
> > the form is minimized and if it is, restore the form to normal.  This
> > event is running as the procedure to write the settings file is begin
> > executed, but the form never get un-minimized.
> >
> > Any idea how to make this happen?
> 
> Assuming this is a Windows.Form application, handle the FormClosed event. The 
> event is passed a FormClosedEventArgs variable, which contains a CloseReason 
> property. This will be one of
> 
> None
>       The cause of the closure was not defined or could not be determined.
> WindowsShutDown
>       The operating system is closing all applications before shutting down.
> MdiFormClosing
>       The parent form of this multiple document interface (MDI) form is 
> closing.
> UserClosing
>       The user is closing the form through the user interface (UI), for 
> example
>       by clicking the Close button on the form window, selecting Close from 
> the
>       window's control menu, or pressing ALT+F4.
> TaskManagerClosing
>       The Microsoft Windows Task Manager is closing the application.
> FormOwnerClosing
>       The owner form is closing.
> ApplicationExitCall
>       The Exit method of the Application class was invoked.
> 
> I think the Automatic Reboot causes a WindowsShutDown to be signalled.
> 
> In any event, I tend to use code like this in my FormClosing events
> 
>       My.Settings.WindowState_MainForm = Me.WindowState
>       If Me.WindowState = FormWindowState.Normal Then
>               My.Settings.Size_MainForm = Me.Size
>               My.Settings.Location_MainForm = Me.Location
>       Else
>               My.Settings.Size_MainForm = Me.RestoreBounds.Size
>               My.Settings.Location_MainForm = Me.RestoreBounds.Location
>       End If
> 
> -- 
> Regards,
> Mike Fry
> Johannesburg
> 


-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to