IF TYPE('thisform.pageframe1')<>"U" ipage = 0 FOR EACH loPage IN THISFORM.PAGEFRAME1.PAGES ipage = ipage + 1 lnorder = loPage.controlcount FOR EACH oControl IN loPage.CONTROLS IF oControl.tabstop = .T. .and. ocontrol.baseclass <>"SHAPE" .and. ; oControl.baseclass <> "LABEL" .and. oControl.readonly=.F. .and. ; oControl.enabled = .T. IF oControl.tabindex < lnorder lnorder = oControl.tabindex lccommand = 'THISFORM.Page'+ALLTRIM(STR(ipage))+'top=Ocontrol.name' &lccommand *Example thisform.page1top='TEXT1' && first control on page1 ENDIF ENDIF ENDFOR ENDFOR ENDIFShould I call gethierarchy before &lccommand to determine it then? If so, do I pass text1 or ocontrol.text1 or what? If I pass 'text1' then 'text1' is returned because gethierarchy is expecting the full hierarchy I think and it checks against 'this' What am I missing?
>* GetFullHierarchy() >LPARAMETER tcHierarchy >LOCAL lcReturn, lnParents, lcParents, lcFirstObject >*Check for the formset presence >lnParents = OCCURS(".", SYS(1272, this) ) >lcParents = REPLICATE(".PARENT", lnParents ) >lcFirstObject = "this" + lcParents >* We use THIS to get the first object in hierarchy as it might be the Formset >IF !EMPTY(lcFirstObject) > loFirstObject = EVAL(lcFirstObject) > * refer to it not by name, but by parents sequence. > IF UPPER(loFirstObject.BASECLASS) = "FORMSET" > tcHierarchy = STRTRAN(tcHierarchy, LOWER(loFirstObject.NAME) + ".", "") && get rid of formset name > ENDIF > loFirstObject = .NULL. >ENDIF >*end formset check >lcReturn = STRTRAN(tcHierarchy, LOWER(THISFORM.NAME) + ".", "thisform.") && like "thisform.grid1.column2.text1" > >RETURN lcReturn>
>>>>*form keypress >>>>CASE nKeyCode = 3 .and. nShiftAltCtrl = 0 && Page Down >>>> NODEFAULT >>>> IF THISFORM.PageFrame.ActivePage < THISFORM.PageFrame.PageCount >>>> THISFORM.PageFrame.ActivePage = THISFORM.PageFrame.ActivePage + 1 >>>> ELSE >>>> THISFORM.PageFrame.ActivePage = 1 >>>> ENDIF >>>> DO CASE >>>> CASE THISFORM.PageFrame.ActivePage = 1 >>>> THISFORM.PageFrame.Page1.controltop.setfocus() >>>>*etc >>>> >>>>DO CASE >>>>CASE nKeyCode = 18 .and. nShiftAltCtrl = 0 && Page Up >>>> IF THISFORM.PageFrame.ActivePage > 1 >>>> THISFORM.PageFrame.ActivePage = THISFORM.PageFrame.ActivePage - 1 >>>> ELSE >>>> THISFORM.PageFrame.ActivePage = THISFORM.PageFrame.PageCount >>>> ENDIF >>>> DO CASE >>>> CASE THISFORM.PageFrame.ActivePage = 1 >>>> THISFORM.PageFrame.Page1.controltop.setfocus() >>>>*Etc >>>> >>>>*page click and dblclick >>>>DODEFAULT() >>>>THIS.controltop.setfocus() >>>>>>>>This works fine because I named the first control on every page 'controltop.' The last control on every page is named 'controlbottom' for the same reason. I also put code in each page's click and dblclick to set focus to the first control on the page so that when the user clicks on a pagetab, focus is on the first control on the page. This is important because F5 is used on most controls to run another popup form when editing detail for the item in the 1st control. If focus in on the pagetab and the user presses F5 (thinking they should be on the first control after clicking on the pagetab) then the default command button on the bottom of the form is clicked and the user is asked if they want to save and exit the form. All of this is working fine and I have no problems.