Rick_Fla Posted March 18, 2004 Posted March 18, 2004 Ok, I have the following code: Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState.Minimized = FormWindowState.Minimized Then Me.Hide() Else Exit Sub End If End Sub Private Sub cntShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cntShow.Click Me.Show() End Sub When I hit the minimize button it works like a charm. The Form hides itself and I am left with the Notify Icon. I have the cntShow_Click as a context menu item on the notify Icon. When I click it, the form does not show it self on screen. If I look in the task bar, I see that the form has been unhidden, but when I click on it, it hides itself again. When I click on the context menu again, the form shows up like I wanted it to in the first place. Is there a check I am not doing that would fix this? Thanks for any help. Quote "Nobody knows what I do until I stop doing it."
TechnoTone Posted March 18, 2004 Posted March 18, 2004 Change your code to: Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() End If End Sub Private Sub cntShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cntShow.Click Me.Show() Me.WindowState = FormWindowState.Normal End Sub Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Experts* Volte Posted March 18, 2004 *Experts* Posted March 18, 2004 If Me.WindowState.Minimized = FormWindowState.Minimized ThenThat needs to be If Me.WindowState = FormWindowState.Minimized Then Quote
Rick_Fla Posted March 18, 2004 Author Posted March 18, 2004 I will try what you suggested. I got it to work this way as well, but your code looks a lot cleaner. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState.Minimized = 1 And blnHide = False Then Me.Hide() Else blnHide = False End If End Sub Private Sub cntShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cntShow.Click Me.Show() blnHide = True Me.WindowState = FormWindowState.Normal End Sub blnhide is a form level var. Quote "Nobody knows what I do until I stop doing it."
Rick_Fla Posted March 18, 2004 Author Posted March 18, 2004 OK, using VolteFace's suggestion, the new code is this: Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() End If End Sub Private Sub cntShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cntShow.Click Me.Show() Me.WindowState = FormWindowState.Normal End Sub Quote "Nobody knows what I do until I stop doing it."
*Experts* Volte Posted March 18, 2004 *Experts* Posted March 18, 2004 Your code is still flawed; If Me.WindowState.Minimized = 1 ThenMe.WindowState is the actual property you have to check. Me.WindowState.Minimized is a constant - if you check the value of that it will always remain the same. Quote
Rick_Fla Posted March 18, 2004 Author Posted March 18, 2004 The last code I posted removed the If Me.WindowState.Minimized = 1 Then Does the last code look fine? Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize If Me.WindowState = FormWindowState.Minimized Then Me.Hide() End If End Sub Private Sub cntShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cntShow.Click Me.Show() Me.WindowState = FormWindowState.Normal End Sub Quote "Nobody knows what I do until I stop doing it."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.