[.net] Getting active form

Started by
3 comments, last by afsajghfd 15 years ago
How can I determine if my app's form is currently active/in the foreground/has focus?
Advertisement
Maybe you can use "System.Windows.Forms.Form.ActiveForm".

It will give you the currently active form. From there you can see if it's the form you're looking for.
I looked at System.Windows.Forms.Form.ActiveForm, but it seems to be the current active form in my application, not on the entire desktop.
what about something like:

System.Windows.Forms.Form.ActiveForm.Focused

Focused returns false if an other form is active.
I was working around this because the OtherApplicationHasPriorityException =/
and well, i found that it can be useful do

if System.Windows.Forms.Form.ActiveForm is this/Me [then] C#/VB

inside the form to know if the form it's active in the foreground.

I revive this hopping help someone else with the same problem

This topic is closed to new replies.

Advertisement