Test for windows hide

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have an application with 3 windows forms. One of which I load at startup
but hide, then show/hide based on users click. How can I test to see if the
windows is hidden, or is at the moment being shown?

Thanks
BrianDH
 
I assume you're loading the "Startup" form from sub_main?

I do something simular for a splash screen.

I'll just copy the class here, but you should get the point... In SubMain I
call Splash.Show
And later in the app I can Splash.Close, you should be able to do something
simular to get SpecialForm.Visible.

---------------------------------------------------------
Public Class Splash
Private Shared splashForm As SplashScreen
Private Shared splashThread As Thread


Shared Sub ShowThread()
If splashForm Is Nothing Then
splashForm = New SplashScreen
End If
Application.Run(splashForm)
End Sub

Public Shared Sub Show()
If Not splashThread Is Nothing Then
Return
End If

splashThread = New Thread(New ThreadStart(AddressOf
Splash.ShowThread))
splashThread.CurrentCulture =
Thread.CurrentThread.CurrentCulture
splashThread.CurrentUICulture =
Thread.CurrentThread.CurrentUICulture
splashThread.IsBackground = True
splashThread.ApartmentState = ApartmentState.STA
splashThread.Start()
While splashForm Is Nothing
Thread.Sleep(New TimeSpan(100))
End While

End Sub

Public Shared Sub Close()
If splashThread Is Nothing Then Return
If splashForm Is Nothing Then Return

Try
If splashForm.IsDisposed Then Return
If splashForm.Handle.Equals(IntPtr.Zero) Then Return
splashForm.Invoke(New MethodInvoker(AddressOf
splashForm.Close))
Catch ex As Exception
Logger.AddLogException(ex,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString)
splashThread = Nothing
splashForm = Nothing
End Try
End Sub

Public Shared Property Status() As String
Get
If splashForm Is Nothing Then Throw New
InvalidOperationException("Splash Form not on screen")
Return splashForm.StatusInfo
End Get
Set(ByVal Value As String)
If splashForm Is Nothing Then Return
splashForm.StatusInfo = Value
End Set
End Property

Public Shared Property Version() As String
Get
If splashForm Is Nothing Then Throw New
InvalidOperationException("Splash Form not on screen")
Return splashForm.VersionInfo
End Get
Set(ByVal Value As String)
If splashForm Is Nothing Then Return
splashForm.VersionInfo = Value
End Set
End Property

Private Sub New()

End Sub
End Class

Create a public property in the form you want to show or hide that does
visibility...
Public Property Visible As Boolean
 
Hi Jeff

The issues is not creating the form and or checking for its creation.
The issues is checking to see if the form's state is visable/shown or
hidden.
The application starts with a MAIN form. Within the Main form I create a
2nd form but hide it. I am looking for a way to know when the user is
viewing / has the 2nd form shown or if it is currently hidden.

Thanks
 
Yes, i can do that. This question was more for just information, was not
like I was stuck, just was wondering.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top