467,084 Members | 1,223 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

Form level focus monitor

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
Nov 27 '06 #1
  • viewed: 911
Share:
4 Replies


"Steve" <St***@nospam.comwrote in message
news:e3**************@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
Nov 27 '06 #2

"Mythran" <ki********@hotmail.comwrote in message
news:eu**************@TK2MSFTNGP03.phx.gbl...
>

"Steve" <St***@nospam.comwrote in message
news:e3**************@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

Nov 27 '06 #3


"Steve" <St***@nospam.comwrote in message
news:O3**************@TK2MSFTNGP06.phx.gbl...
>
"Mythran" <ki********@hotmail.comwrote in message
news:eu**************@TK2MSFTNGP03.phx.gbl...
>>

"Steve" <St***@nospam.comwrote in message
news:e3**************@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
Nov 27 '06 #4

"Mythran" <ki********@hotmail.comwrote in message
news:O4**************@TK2MSFTNGP06.phx.gbl...
>

"Steve" <St***@nospam.comwrote in message
news:O3**************@TK2MSFTNGP06.phx.gbl...
>>
"Mythran" <ki********@hotmail.comwrote in message
news:eu**************@TK2MSFTNGP03.phx.gbl...
>>>

"Steve" <St***@nospam.comwrote in message
news:e3**************@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

Nov 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by bradwiseathome@hotmail.com | last post: by
1 post views Thread by Uchiha Jax | last post: by
2 posts views Thread by chuckdfoster | last post: by
7 posts views Thread by Dave Booker | last post: by
44 posts views Thread by John Dann | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.