Click to See Complete Forum and Search --> : focus problem
phil m
March 26th, 2001, 07:19 PM
I have a mess of controls on my form.
Using the arrow keys the focus passes from one command button to the next - fine. But then it disappears off the screen. Nothing has the focus.
How can I check if nothing has the focus then give focus to command1.
Cheers a lot
Phil
shree
March 26th, 2001, 07:35 PM
It doesn't happen that "nothing has the focus". Something has the focus, its only that it is not seen. For example, we do not see a picturebox having focus. Identify such elements and set their tabstop property to false. You can do it in one go during form load like
dim aControl as Control
for each aControl in Controls
if TypeOf aControl is PictureBox then aControl.Tabstop = false
next
To identify which control has the focus, put a timer on your form, set its interval to 2 seconds, say, and in the timer event, write
MsgBox ActiveControl.Name
Now play with your keys. When the focus seems to disappear, wait some time and the name of the control with the focus will pop up.
John G Duffy
March 26th, 2001, 07:36 PM
Something has the focus somewhere. Check the TabIndex property of the last control that gained and lost the focus. Then look for a control with a higher number. The control may be hidden behind another, Could be a menu item or a control that does not display the Focus rectangle.
John G
phil m
March 26th, 2001, 08:46 PM
Hmm - thanks guys.
Yes, focus was being trapped by picture1. Once there, the arrow keys no longer switch focus though the tab key does.
I can do something about that - no problem - thanks very much.
Phil
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.