Determining which control has input focus?

  • Thread starter Thread starter Dave Veeneman
  • Start date Start date
D

Dave Veeneman

What's the best way to determine in code which control on a form has input
focus?

I'm programming an edit menu (the usual cut, copy, paste), which needs to
target one of several text boxes on its form. Specifically, the menu needs
to target the text box that has the input focus. For the moment I'm assuming
there will be no controls on the form except the menu and the text boxes.

I've found code to drive the clipboard edit methods. But none of the
examples shows how to determine which text box has the input focus. They all
assume the method there is only one text box on the form. So, what I'm
puzzling over is this: Is there a simple way to determine which text box has
the focus, or do I need to iterate through all controls on the form?

Thanks.
 
I found my answer. Forms (and other containers) have an ActiveControl
property that returns the control with focus.
 
Back
Top