>> >>FOR EACH oCont IN Thisform.Controls >> IF oCont.Baseclass = 'Pageframe' >> FOR EACH Ctrl IN oCont.Page1.Controls >> IF PEMSTATUS(Ctrl,'TabIndex',5) = .T. AND ; >> PEMSTATUS(Ctrl,'Readonly',5) = .T. AND ; >> Ctrl.Readonly = .F. >> Ctrl.SetFocus() >> EXIT >> ENDIF >> ENDFOR >> EXIT >> ENDIF >>ENDFOR >> >>>What is happening is that instead the focus goes to the second control (tabindex=2) is going to third (tabindex=3). What is wrong?
#define c_mnogo 1e6 local tajje, oCtl * initialize the variable to remember the minimal tabindex to an impossibly high value tajje=c_mnogo oNjega=.null. for each oCtl in thisform.controls if PEMSTATUS(oCtl, "SetFocus",5 ) and type("oCtl.tabindex")="N" and oCtl.visible and oCtl.enabled * check if it's the minimal value encountered, and if it is, create a reference to that control if oCtl.tabindex<tajje tajje=oCtl.tabindex oNjega=oCtl endif endif endf dodefault() if tajje<c_mnogo oNjega.SetFocus endifI'm not checking for read-only, because, theoretically, the first control to receive focus may be read-only, and if it's a memo, the user should be able to read, copy, scroll etc, which is still possible if it's read only. There's also a case of a long string in a short textbox, where the user should be given a chance of horizontal scroll (how is it done with a mouse?). Besides, it says "readable", not "writable" at the beginning of the message.