-
testing if Form is active
I have a thread timer that works and calls a sub below, what I want the sub to do is refresh the form for the user. The issue I have is if the form isn't in focus (say the screensaver kicked on or you bring up another program or something) then the code crashes.
When the timer expires it calls this sub
Shared Sub CheckStatus(ByVal State As Object)
Dim myform As Form
myform = frmMain.ActiveForm
myform.Activate()
myform.Refresh()
'MessageBox.Show("I am refreshed")
myform = Nothing
End Sub
the problem is if frmMain is not the active form (because of screen saver or whatever) then myform doesn't get set and crashes when it tries to refresh it.
My question is how can I test if frmMain is active and if it is refresh it if not go on doing whatever?
Thanks
-
Well, i'm a C# person, but just do a try and catch. If it fails, you know it's not active.
Joel
-
That worked so it wouldn't crash but is there a more elegant way to handle if the form is active?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks