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
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
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.