469,648 Members | 1,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

Getting the window/control that lost the focus

When processing the OnGotFocus event, I need to know the window/control that
lost the focus. Is there a way to determint this?

With MFC, you could use OnSetFocus which passed you the window that lost the
focus. It there something similar with a c# control.
May 15 '07 #1
1 2469
On Tue, 15 May 2007 14:37:01 -0700, ja***@nospam.com
<ja************@discussions.microsoft.comwrote:
When processing the OnGotFocus event, I need to know the window/control
that lost the focus. Is there a way to determint this?
Not sure...nothing explicit is in the GotFocus event args passed in, so it
doesn't look like it.

However, you could override the WndProc for your control, handling the
WM_SETFOCUS message. You get the window handle that lost the focus in
that message (in the wParam), and then can use the Control.FromHandle()
method to get the actual control.

Seems like an odd oversight for the GotFocus event, considering the
underlying window message provides the information you want, *and*
previous Windows API wrappers (eg MFC) provided that information too.

Pete
May 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Barry Svee | last post: by
31 posts views Thread by Benno Bös | last post: by
3 posts views Thread by NeverLift | last post: by
4 posts views Thread by Sameh Ahmed | last post: by
6 posts views Thread by Jack | last post: by
2 posts views Thread by =?Utf-8?B?VmFuZXNzYQ==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.