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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus Problem

Status
Not open for further replies.

scroome

Technical User
Jan 10, 2003
3
GB
I am writing a simple program in vb 6 but need to stop an object getting focus when the program runs, but I cannot use the visible or lock properties.

Does any one know how to stop a object getting focus at runtime without using the properties listed above ?

Thanks in advance.
 
Maybe the tabindex is set to 1 and that is why it's getting focus?
 
Set the tabstop to false in the property window of the control.. All the Best
Praveen Menon
pcmin@rediffmail.com
 
Do you mean 'stop it from getting focus immediately'. If so PraveenMenon's answer will do you.

If you mean 'stop it from getting focus ever' then you also need to do something like this:
Private Sub Command1_GotFocus()
Command2.SetFocus
End Sub

You will need to ensure that there is no HotKey combination for the command
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
A little trick I learned somewhere on this forum which might provide a similar solution to the last post, but doesn't require you to hard code the next control is to simple set the .Enabled property to false, then immediately to true again. You could probably do this in the GotFocus event. What this does is temporarily disable the control, causing it to lose focus. The focus immediately goes to the next appropriate control in the tabindex. When you enable the original control again, it is still active, but won't have the focus.

Doing this in the GotFocus event would prevent the control from ever getting the focus. Actually, it would prevent it from keeping the focus, but from the user's perspective, it would prohibit it from getting the focus. BlackburnKL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top