473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Test for windows hide

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
Nov 21 '05 #1
4 1538
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().De claringType.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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
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

Nov 21 '05 #2
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

"Jeff Sheldon" wrote:
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().De claringType.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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
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


Nov 21 '05 #3
Why not just set a private variable to true whenever the 2nd form is shown.
"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
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

"Jeff Sheldon" wrote:
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().De claringType.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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
> 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


Nov 21 '05 #4
Yes, i can do that. This question was more for just information, was not
like I was stuck, just was wondering.

Thanks

"Jeff Sheldon" wrote:
Why not just set a private variable to true whenever the 2nd form is shown.
"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
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

"Jeff Sheldon" wrote:
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().De claringType.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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
> 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


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sam | last post by:
I wrote a script to show or hide items in an HTML list (<ul id="stuff">) depending on whether a list-item's CLASS attribute matches an input string (catString), which is chosen from a SELECT menu....
30
by: Kelsey Bjarnason | last post by:
I'm online at the moment, trying to help someone with a programming problem. His code, which isn't as bad as it could be, is trying to open a file "file.in". The file exists, is called...
5
by: Xarky | last post by:
Hi, I am creating a windows form, and when a specified event occurs (button click), I am hiding the windows form and opening a new windows form. When opening the new windows form and closing...
1
by: Asad | last post by:
Hi, I am trying to write my first Windows application using VB.NET and I am having some difficulties designing the UI. Basically its one Windows Form with 4 menus on the top (no drop downs)....
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
2
by: Rain | last post by:
Does anyone know the code in C# or snippet or API so i can hide and show the windows taskbar? Many people have suggested using ShowWindow and FindWindow or the ABM_SETSTATE but i am having problem...
7
by: Steve954 | last post by:
I recently installed and started using VS2005 on a Windows XP Pro machine. When creating a new windows forms project I find that I am unable to hide any forms using the me.hide() or me.visible =...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.