By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

WindowState remaining Minimized despite being set to Normal

100+
P: 116
Hi.

I have a form that has the following code onload.

Expand|Select|Wrap|Line Numbers
  1. If Not My.Settings.MyLocation.IsEmpty Then
  2.     Me.Location = My.Settings.MyLocation
  3. End If
  4. If Not My.Settings.MySize.IsEmpty Then
  5.     Me.Size = My.Settings.MySize
  6. End If
  7. Me.WindowState = FormWindowState.Normal
  8.  
When the form is closed it decides if it should store the new size/location based on the following code.

Expand|Select|Wrap|Line Numbers
  1. If Me.WindowState = FormWindowState.Normal Then
  2.     My.Settings.MySize = Me.Size
  3.     My.Settings.MyLocation = Me.Location
  4.     My.Settings.Save()
  5. End If
  6.  
Every time I open the form it finds the correctly stored size of 1500,700.

However if the form was closed by right-clicking whilst it was minimised, it seems to ignore these settings and the requested Normal window state and remains minimised when loaded without any way to reinstate it.

This only seems to occur when the form is opened, minimised, closed whilst minimised then opened again. (Opening is done via a Show() command). The first loading seems to be ok.

Any ideas what on earth is going on and/or how to force the form to open at the stored size/location and normal state every time, no matter what state it was in when closed?

Thanks
Jan 5 '14 #1
Share this Question
Share on Google+
1 Reply


100+
P: 116
Ok seems to be no straightforward answer so I'll post my solution here.

I had to hack around this by setting the WindowState to Normal immediately prior to closing so it always closes in Normal state.

It means the window briefly shows before closing but that's ok if there's no proper solution.
Jan 9 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.