FIX: Can't Move Focus from a Toolbar to an Object on a Form (132910)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
This article was previously published under Q132910 SYMPTOMS
Attempts to use SetFocus to move the focus from an object in a toolbar to
an object on a form within a formset does not work. The focus never leaves
the previously active control, which is another object on the form. This
problem occurs only with formsets.
WORKAROUNDStep-by-Step Workaround
Create an instance of the toolbar as a separate object and the form as a
separate object. Then the code _SCREEN.ActiveForm.Text1.SetFocus
in the command button on the toolbar works just fine. For example:
- Use this command:
- Select the ToolBar1 form.
- On the Form menu, click Remove Form.
- Press CTRL+W to save your work and exit from the Form Designer.
- Use this command:
MODIFY CLASS mytoolbar OF mytestlib
- Double-click the command button on the Toolbar.
- Replace this code:
THISFORMSET.FORM1.Text1.SetFocus
with this code:
_SCREEN.ActiveForm.Text1.SetFocus
- Press CTRL+W to save your work and exit from the Class Designer.
- Type the following commands in the Command window:
SET CLASSLIB TO mytestlib.vcx
oToolBar = CREATEOBJECT("mytoolbar")
oToolBar.SHOW
DO FORM myformset.
- Click the second text box object (the one below) on Form1.
- Click the New button on the toolbar.
Alternative Step-by-Step Workaround
Another workaround if you must use a formset is to place a timer object on
the form that uses SetFocus to move the focus to Text1 on the form. For
example:
- Use the following command:
MODIFY CLASS mytoolbar OF mytestlib.
- Double-click the command button on the toolbar.
- Replace this code:
THISFORMSET.FORM1.Text1.SetFocus
with this code:
THISFORMSET.FORM1.Timer1.Enabled = .T.
- Add a timer object to Form1.
- Set the timer's Interval property to 10.
- In the timer's Timer event, add this code:
THISFORMSET.FORM1.Text1.SetFocus
THIS.Enabled=.F.
- Press CTRL+W to save the formset and exit from the Form Designer.
- Use this command:
- Click the second Text Box object (the one below) on Form1.
- Click the New button on the toolbar.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. This problem has been fixed in
Visual FoxPro 5.0 for Windows.
Modification Type: | Major | Last Reviewed: | 9/30/2003 |
---|
Keywords: | kbBug kbfix kbvfp500fix KB132910 |
---|
|