How to check if form is open

Thread Solved

Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

How to check if form is open

 
0
  #1
Aug 20th, 2007
How do I check if a form is open (not only loaded, but also open)
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: How to check if form is open

 
0
  #2
Aug 20th, 2007
Originally Posted by plusplus View Post
How do I check if a form is open (not only loaded, but also open)
What I mean is, I know how to check if it's loaded, but I want to know if it's being shown at this time
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to check if form is open

 
0
  #3
Aug 20th, 2007
Hi,

Copy this Function and Pass the form name. If form is loaded and not shown, then it's Visible property will be false, u need to check that:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub CheckFormStatus(Myform As Form)
  2. Dim objForm As Form
  3. Dim FlgLoaded As Boolean
  4. Dim FlgShown As Boolean
  5. FlgLoaded = False
  6. FlgShown = False
  7. For Each objForm In VB.Forms
  8. If (Trim(objForm.name) = Trim(Myform.name)) Then
  9. FlgLoaded = True
  10. If objForm.Visible Then
  11. FlgShown = True
  12. End If
  13. Exit For
  14. End If
  15. Next
  16. MsgBox "Load Status: " & FlgLoaded & vbCrLf & "Show Status:" & FlgShown
  17. End Sub

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: How to check if form is open

 
0
  #4
Aug 20th, 2007
Thank you , what you are saying is if it's loaded, check if its visible. Works perfectly. What is Trim in the code you gave me? I did it without, is there any reason it's needed?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to check if form is open

 
0
  #5
Aug 20th, 2007
Hi,

If it is for ur Timer Form..(previous thread), then I suggest an alternative solution. When u show the subForm in Modal, Disable the Timer, And Enable the timer In UnLoad event of the subForm. This way u need not check if the form is loaded/visible and all the stuff..

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to check if form is open

 
0
  #6
Aug 20th, 2007
Hi,

Trim is not necessariy required, but just to be on the safer side, using Trim..

REgards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 189
Reputation: plusplus is an unknown quantity at this point 
Solved Threads: 16
plusplus plusplus is offline Offline
Junior Poster

Re: How to check if form is open

 
0
  #7
Aug 20th, 2007
Thank you so much for that idea. My project is just getting bigger and bigger and every time I add another thing, I have to make sure it doesn't cause any problems to my old stuff. I'm at the end now and trying out every single possibility, to make sure it all works.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 4
Reputation: arbalu is an unknown quantity at this point 
Solved Threads: 0
arbalu arbalu is offline Offline
Newbie Poster

Re: How to check if form is open

 
0
  #8
Sep 17th, 2008
Just put the following code in your form closing event (for vb.net (VS2008). For more detail http://developerskb.blogspot.com
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  2. If frmOrdDet.Visible = True Then
  3. MsgBox("Costing detail input form is in active! Close it before exit", MsgBoxStyle.Information)
  4. frmOrdDet.Focus()
  5. e.Cancel = True
  6. Else
  7. Dim dr As Object
  8. If e.CloseReason = CloseReason.UserClosing Then
  9. dr = MsgBox("Exit Application..?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question)
  10. If dr = vbYes Then
  11. frmLogin.Dispose()
  12. Me.NotifyIcon.Dispose()
  13. e.Cancel = False
  14. Else
  15. e.Cancel = True
  16. End If
  17. End If
  18. End If
  19. End Sub
Last edited by arbalu; Sep 17th, 2008 at 4:36 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 1
Reputation: alaguvadi is an unknown quantity at this point 
Solved Threads: 0
alaguvadi alaguvadi is offline Offline
Newbie Poster

Re: How to check if form is open

 
0
  #9
Mar 7th, 2009
Thanks ur code worked for me....

Originally Posted by QVeen72 View Post
Hi,

Copy this Function and Pass the form name. If form is loaded and not shown, then it's Visible property will be false, u need to check that:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub CheckFormStatus(Myform As Form)
  2. Dim objForm As Form
  3. Dim FlgLoaded As Boolean
  4. Dim FlgShown As Boolean
  5. FlgLoaded = False
  6. FlgShown = False
  7. For Each objForm In VB.Forms
  8. If (Trim(objForm.name) = Trim(Myform.name)) Then
  9. FlgLoaded = True
  10. If objForm.Visible Then
  11. FlgShown = True
  12. End If
  13. Exit For
  14. End If
  15. Next
  16. MsgBox "Load Status: " & FlgLoaded & vbCrLf & "Show Status:" & FlgShown
  17. End Sub

Regards
Veena
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC