Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Which Control Has Focus

Status
Not open for further replies.

Linguist

Technical User
Jul 11, 2000
40
0
0
US
Background: I am developing an application that has a RichTextBox, 2 TextBoxes, and a DBGrid on the same form.

Problem: I would like to be able to set up a test to determine which of the above controls has focus at any given point in time. Then, depending on which control has focus, the application will procede accordingly.

Any suggestions will be welcome.

Thanks,
-Bob
 
Just an idea:

Why not have a global variable (string or enum) that will be set in each event of set_focus of each one of the controls. something like this:

Public Enum Focused
Text1 = 0
Text2 = 1
Command1 = 2
End Enum

Public whoIsFocused As Focused


Private Sub Command1_GotFocus()
whoIsFocused = Command1
End Sub

Private Sub Text1_GotFocus()
whoIsFocused = Text1
End Sub

Private Sub Text2_GotFocus()
whoIsFocused = Text2
End Sub


What do you think?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top