Question : Me.Visible AND Me.WIndowState = WindowState.Normal doesn't work

Hi, damn this is irritating - please provide relief..LOL.

1 - I want my form to start up in the invisible state.  So, in the form_load event, I have Me.Visible = False (this does'nt work in the form_load event) (Please don't suggest Opacity as a solution as this doesn't disable the controls on the form face)  I am using a timer and making it invisible there, but there is a small slice of time where the initial load of the form will show the screen.

2 - My form is normally invisible, so when a certain event fires on the form, I need to make the form visible, so I make it visible, Me.Visible = True, this works, but if the form was previously minimized by the user, I cannot restore it to the normal state.  The following simply doesn't work - > Me.WIndowState = FormWindowState.Normal doesn't work  
How do I force a restore of the form regardless of previous state.

Some sanity greatly appreciated...

Answer : Me.Visible AND Me.WIndowState = WindowState.Normal doesn't work

Not sure why Opacity() isn't working for you...

At design-time, I set Opacity to 0 (zero) and ShowInTaskBar to False and the form is COMPLETELY invisible on start.

I added a Timer to the Form just to make it pop back up:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 5000
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Stop()
        ShowForm(True)
    End Sub

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            ShowForm(False)
            Me.Timer1.Start() ' just to make it pop back up after 5 seconds...
        End If
    End Sub

    Private Sub ShowForm(ByVal MakeVisible As Boolean)
        If MakeVisible Then
            Me.Show()
            If Me.WindowState = FormWindowState.Minimized Then
                Me.WindowState = FormWindowState.Normal
            End If
            Me.ShowInTaskbar = True
            Me.Opacity = 1
        Else
            Me.ShowInTaskbar = False
            Me.Hide()
            Me.Opacity = 0
        End If
    End Sub

End Class
Random Solutions  
 
programming4us programming4us