On Thu, 15 May 2008 10:03:01 -0700, Vanessa
<Va*****@discussions.microsoft.comwrote:
Hi all!
I have one combobox, two grids and nine textbox. All textbox are tab
index
one following another. When I press tab I go to the next textbox. How
can I
known if I click on another component, like the combobox?
Your question is somewhat ambiguous. The GotFocus and LostFocus events
will tell you about focus changes for specific controls. You can use
these to track focus changes among your own controls.
Unfortunately, when one control loses focus, the LostFocus event
associated with that doesn't tell you which control is getting focus, nor
does the GotFocus event tell you which control lost focus. However, if
you're subscribed to the approprite events for all of your controls, then
you can track that information yourself.
Barring that, you can override the WndProc() method and watch for
WM_KILLFOCUS and WM_SETFOCUS messages. These include a handle to the
"other" control window, which you may be able to pass to
Control.FromHandle() to resolve back to the actual Control instance that's
relevant.
Pete