|
-
May 16th, 2008, 11:27 AM
#1
Thread Starter
Member
Application LostFocus
Hi
I'm creating a small utility which will run out of the notify bar. If the user clicks the notify icon it displays a form in the bottom right hand corner - this works perfectly. However I would like to listen for if the user clicks on another program (say Excel), the program will detect its lost focus and will minimise the form.
I've tried form_LostFocus but that doesnt seem to work
Any thoughts please?
Thanks
Jay
-
May 16th, 2008, 11:42 AM
#2
Lively Member
Re: Application LostFocus
Let's see if I understand you correctly:
When the form is opened in the bottom right hand corner, it has focus? When the user moves away from that form, say to another application, you want to minimize that form so it's not hanging open?
If this is in fact what you mean, then you don't have to look for your application losing focus, but rather, just that form. Let's assume it's called "Form1". You want the Lost Focus Event.
Code:
Private Sub Form1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
'Do your minmize here
End Sub
-
May 16th, 2008, 11:48 AM
#3
Junior Member
Re: Application LostFocus
It is working on my side. I have used the following code
Code:
Private Sub Form1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
Me.WindowState = FormWindowState.Minimized
End Sub
When Focus is removed from Form1 it gets minimized automatically.
Also you can try the DeActivate Event
Code:
Private Sub Form1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
Me.WindowState = FormWindowState.Minimized
End Sub
-
Jul 15th, 2008, 12:14 PM
#4
New Member
Re: Application LostFocus
Don't use LostFocus. See what happens if you do this:
Code:
Me.textbox1.Focus() ' textbox1 placed on Form1
Better use the Deactivate event handler.
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
|
Click Here to Expand Forum to Full Width
|