Home All Groups Group Topic Archive Search About

Form level focus monitor

Author
27 Nov 2006 4:10 PM
Steve
I would like to write a routine that will monitor every focus change on the
form and report the name of the control that got focus. I know I could put
code in the gotfocus event of every control and call a central routine, but
is there a way to monitor gotfocus events from one central form level
procedure?

Thanks,

-Steve

Author
27 Nov 2006 5:39 PM
Mythran
"Steve" <Steve@nospam.com> wrote in message
news:e3ZEP6jEHHA.4680@TK2MSFTNGP04.phx.gbl...
>I would like to write a routine that will monitor every focus change on the
>form and report the name of the control that got focus. I know I could put
>code in the gotfocus event of every control and call a central routine, but
>is there a way to monitor gotfocus events from one central form level
>procedure?
>
> Thanks,
>
> -Steve
>
>

Not that I'm aware of.  What you can do, though, is something similar to
your gotfocus event handler.  Create a procedure with the same signature as
your gotfocus event.  In your form load event, loop through all controls on
the form (that you want to log when they get the focus) and attach the got
focus event to the procedure you created above.  Have this procedure
monitor/log your focus.

HTH,
Mythran
Author
27 Nov 2006 6:50 PM
Steve
Show quote Hide quote
"Mythran" <kip_pot***@hotmail.com> wrote in message
news:eu1R3rkEHHA.4208@TK2MSFTNGP03.phx.gbl...
>
>
> "Steve" <Steve@nospam.com> wrote in message
> news:e3ZEP6jEHHA.4680@TK2MSFTNGP04.phx.gbl...
>>I would like to write a routine that will monitor every focus change on
>>the form and report the name of the control that got focus. I know I could
>>put code in the gotfocus event of every control and call a central
>>routine, but is there a way to monitor gotfocus events from one central
>>form level procedure?
>>
>> Thanks,
>>
>> -Steve
>>
>>
>
> Not that I'm aware of.  What you can do, though, is something similar to
> your gotfocus event handler.  Create a procedure with the same signature
> as your gotfocus event.  In your form load event, loop through all
> controls on the form (that you want to log when they get the focus) and
> attach the got focus event to the procedure you created above.  Have this
> procedure monitor/log your focus.
>
> HTH,
> Mythran
>
>
Thanks Mythran,

Sounds like a good idea. Problem is that I'm not sure how to attach the got
focus event to the procedure.
Could I impose on you for some sample code or a hint at where to look in
MSDN?

Thanks again,

Steve
Author
27 Nov 2006 9:05 PM
Mythran
Show quote Hide quote
"Steve" <Steve@nospam.com> wrote in message
news:O3LKZTlEHHA.4952@TK2MSFTNGP06.phx.gbl...
>
> "Mythran" <kip_pot***@hotmail.com> wrote in message
> news:eu1R3rkEHHA.4208@TK2MSFTNGP03.phx.gbl...
>>
>>
>> "Steve" <Steve@nospam.com> wrote in message
>> news:e3ZEP6jEHHA.4680@TK2MSFTNGP04.phx.gbl...
>>>I would like to write a routine that will monitor every focus change on
>>>the form and report the name of the control that got focus. I know I
>>>could put code in the gotfocus event of every control and call a central
>>>routine, but is there a way to monitor gotfocus events from one central
>>>form level procedure?
>>>
>>> Thanks,
>>>
>>> -Steve
>>>
>>>
>>
>> Not that I'm aware of.  What you can do, though, is something similar to
>> your gotfocus event handler.  Create a procedure with the same signature
>> as your gotfocus event.  In your form load event, loop through all
>> controls on the form (that you want to log when they get the focus) and
>> attach the got focus event to the procedure you created above.  Have this
>> procedure monitor/log your focus.
>>
>> HTH,
>> Mythran
>>
>>
> Thanks Mythran,
>
> Sounds like a good idea. Problem is that I'm not sure how to attach the
> got focus event to the procedure.
> Could I impose on you for some sample code or a hint at where to look in
> MSDN?
>
> Thanks again,
>
> Steve
>
>
>

Sure, try AddHandler and RemoveHandler :)  Look those up in MSDN..

HTH,
Mythran
Author
28 Nov 2006 1:56 PM
Steve
Show quote Hide quote
"Mythran" <kip_pot***@hotmail.com> wrote in message
news:O4WzWfmEHHA.4832@TK2MSFTNGP06.phx.gbl...
>
>
> "Steve" <Steve@nospam.com> wrote in message
> news:O3LKZTlEHHA.4952@TK2MSFTNGP06.phx.gbl...
>>
>> "Mythran" <kip_pot***@hotmail.com> wrote in message
>> news:eu1R3rkEHHA.4208@TK2MSFTNGP03.phx.gbl...
>>>
>>>
>>> "Steve" <Steve@nospam.com> wrote in message
>>> news:e3ZEP6jEHHA.4680@TK2MSFTNGP04.phx.gbl...
>>>>I would like to write a routine that will monitor every focus change on
>>>>the form and report the name of the control that got focus. I know I
>>>>could put code in the gotfocus event of every control and call a central
>>>>routine, but is there a way to monitor gotfocus events from one central
>>>>form level procedure?
>>>>
>>>> Thanks,
>>>>
>>>> -Steve
>>>>
>>>>
>>>
>>> Not that I'm aware of.  What you can do, though, is something similar to
>>> your gotfocus event handler.  Create a procedure with the same signature
>>> as your gotfocus event.  In your form load event, loop through all
>>> controls on the form (that you want to log when they get the focus) and
>>> attach the got focus event to the procedure you created above.  Have
>>> this procedure monitor/log your focus.
>>>
>>> HTH,
>>> Mythran
>>>
>>>
>> Thanks Mythran,
>>
>> Sounds like a good idea. Problem is that I'm not sure how to attach the
>> got focus event to the procedure.
>> Could I impose on you for some sample code or a hint at where to look in
>> MSDN?
>>
>> Thanks again,
>>
>> Steve
>>
>>
>>
>
> Sure, try AddHandler and RemoveHandler :)  Look those up in MSDN..
>
> HTH,
> Mythran
>
>

Just what I was looking for. Thanks again.

-Steve