User input focus detecting?

  • Thread starter Thread starter Pieter Breed
  • Start date Start date
P

Pieter Breed

Hi,

Is there a way to determine if your winform application has the current
user focus?

I am looking to implement something that works somewhat like Outlook's
new email notify window. The specific behaviour that I am trying to
replicate is that if you don't give attention to the window it fades
out again after a while, but if you hover over it or click on it it
does not.

So my windows must fade in, show something, and only if you didn't
click on it (ie give it focus) then fade out again.

Regards,
Pieter
 
Hi Pieter,

I think you should you the MouseHover event of the form to detect if tthe
user wants to activate your notification form, and then activate the form and
disable your "fadeout timer".

You can test which event is fired like this:

Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseEnter
Debug.WriteLine("MouseEnter")
End Sub

Private Sub Form1_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseLeave
Debug.WriteLine("MouseLeave")
End Sub

Private Sub Form1_MouseHover(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseHover
Debug.WriteLine("MouseHover")
End Sub

Hope this helps,

Joris
 
Hi Pieter!

What about simply using the someForm.Focused boolean property?


- Peder -
 
Back
Top