Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Workaround for a bug
Message
From
14/06/2001 20:03:51
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00519598
Message ID:
00519765
Views:
15
This message has been marked as a message which has helped to the initial question of the thread.
You probably do not want to set first focus to any object which has a controlcount such as GRID,PAGE,CONTAINER et al.

revised method code is as follows:
local loMinControl
loMinControl = .null.
For each loControl in ThisForm.Controls
  if not if pemstatus(locontrol,'controlcount',5)
    if pemstatus(locontrol,'setfocus',5) and locontrol.enabled
      if isnull(loMinControl) or loControl.tabindex < lomincontrol.tabindex
        lomincontrol = locontrol
      endif
    endif
  endif
endfor

note: loMincontrol is a hanging reference until end of setfocus

if not isnull(loMincontrol)
  loMinControl.setfocus()
endif
loMinControl = .null.
>>>>I did force a SetFocus() on one of my control whenever I call the Refresh() method. This solves the problem.
>>>>
>>>>I was wondering, instead of adding a control, is there a way to detect the control #1 in the tab sequence so we can focus on that?
>>>
>>>You could loop through the Controls() collection looking for the first visible control that has a SetFocus method that is not a grid, but I think that would be a PITA.
>>
>>The advantages of it is that we will set the focus to the first control of the form, the focus will be on a visible one so we will see and we won't have to handle an extra control to handle that workaround.
>
>I have only tested this code for the conditions in it. There may be other factors that prevent a control from receiving focus, like visible property.
>local loMinControl
>loMinControl = .null.
>for each loControl in ThisForm.Controls
>   if isnull(loMinControl)
>      if upper(loControl.BaseClass) <> "GRID" and pemstatus(loControl, 'SetFocus', 5) and loControl.Enabled
>         loMinControl = loControl
>      endif
>      loop
>   endif
>   if upper(loControl.BaseClass) <> "GRID" and pemstatus(loControl, 'SetFocus', 5) and loControl.Enabled
>      if loControl.TabIndex < loMinControl.TabIndex
>         loMinControl = loControl
>      endif
>   endif
>endfor
>if not isnull(loMinControl)
>   loMinControl.SetFocus()
>endif
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform