Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP5 and _CUROBJ
Message
From
27/11/1998 15:01:27
 
 
To
25/11/1998 23:45:16
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00161344
Message ID:
00162006
Views:
41
Hi Bernard,

They say one always thinks better on a full stomach, so after taking the day off yesterday for our Thanksgiving holiday (and stuffing myself with turkey and all the goodies) here's a solution I came up with which seems to work.

1) add an array property called aControls to your form

2) in the INIT of the form, populate the array with the tabindex and name of all its controls, and sort it
with thisform
   for i = 1 to .controlcount
      dimension .aControls[i, 2]
      .aControls[i, 1] = .controls[i].tabindex   && so we can sort by tab order
      .aControls[i, 2] = .controls[i].name       && so we can ascan for the name
   endfor
   asort(.aControls)
endwith
3) in the Click event of the command button, use ASCAN() to locate the name of "this" (the command button) and add 2 to get the name of the control which comes next in the tab index sequence, then SetFocus to that control.
local lnElement, lcControlName
with thisform
   * point to the name of the next control
   lnElement = ascan(.aControls, this.name) + 2	
   if lnElement <= alen(.aControls)            && be sure it's valid
      lcControlName = .aControls[lnElement]    && get the name of the control
      .&lcControlName..SetFocus()              && set focus to that control
   endif
endwith
This should do what you want, since it doesn't require knowing the name of the control whose focus you want to set, only how far away it is in the tab order (similar to adding a number to OBJNUM in Fox 2.x).

HTH,
Rick





>>>I know aboutthe SETFOCUS Method. As mentioned above, I do not know WHAT "Control" is.
>>>
>>>In the FPW2.6 code I did not care as I used _CUROBJ = OBJNUM(currentfield)+1
>>>This set the focus to the NEXT tab order field without the need of knowing what its name or variable was.
>>>
>>>THIS IS WHAT I NEED TO DO!!
>>>
>>>Bernard
>>
>>You can return a numeric value from the VALID event of a control to specify which control gets the focus. Quoting from the VFP5 help file:
>>· If a positive value is returned, the value specifies the number of controls the focus advances. For example, if the Valid event returns 1, the next control gets the focus.
>>· If a negative value is returned, the value specifies the number of controls the focus moves back. For example, if the Valid event returns –1, the previous control gets the focus.
>>
>>HTH,
>>Rick
>
>
>Rick
>I tried this in a form with 2 text boxes and a command button. It works as it should?? If I tab from field to field the valid is called and the control works as in the help. But if i call the VALID of the field from a form method (which I need to do), nothing happens.
>
>I added code in the click of the button
>Thisform.text1.setfocus $$focus was still on the command button
>*now text1 is gotfocus()
>Thisform.text1.Valid && valid has one line - return 2.
>
>This should put the focus onto the next field+1 which is the command button - but it does not.Text1 still has the focus.
>
>Any other ideas or did I do something wrong??
>
>Bernard
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform