Re: Application Focus

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Thu, 17 Jan 2008 22:17:28 -0800, NvrBst <nvrbst@xxxxxxxxx> wrote:

Is there a quick way to see if my application has focus?

Define "focus".

I've tried "this.Focused" but it doesn't return true if one of its
childen controls is what has focus (IE I just clicked a button to
check "this.Focused"). If I run the "this.myBtn.Focused" as the
button click event then I get "true". Ideally I would want something
like application.focused.

I see System.Windows.Window.IsActive, available in .NET 3.0 and later. Prior to that, I'm not sure you can do it from .NET. You may have to use p/invoke to get at the unmanaged function.

Pete
.


Quantcast