Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine what 1st control on a page is or tabord
Message
 
To
13/05/2004 10:30:18
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00903578
Message ID:
00903594
Views:
17
>What syntax can I use to set focus to a property on the form whose name is contained in a form property? I've had problems with this in the past...

You mean the control on the form, right?

You can use EVAL() function for that. I suggest you to store the full hierarchy name of the control, that can be obtained with SYS(1272) and replace the form name with "thisform". I use the following method for it:
* 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
>Thanks for the idea Nick,
>
>I do have code in some of the forms that steps through each page's control on the form for other purposes so I can definitely determine this value using that method. I guess I should also check for tabstop = .T. then. However, lets say that I then retrieve the name of the control using this method in the form's init and store the value in a form property so it can be referenced in the form's keypress and the page's click and dblclick. What syntax can I use to set focus to a property on the form whose name is contained in a form property? I've had problems with this in the past...
>
>
>
>
>>Tracy, is control.TabIndex property of any help in your situation?
>>
>>>I have many forms with multiple pages in a pageframe. About half of these are based on a class and the other half are not. In those that are not based on a class, I have the same code in every form's keypress:
>>>
>>>*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.
>>>
>>>Here is the problem:
>>>
>>>I need to implement the same functionality on the other set of forms which all are derived from the same form class. The other half of the forms based on a form class do not do this in anymeans so far. Each control on every page has a unique name. Since all forms are based on the class, I would like to be able to determine what the first control in the tab order on the page is so I can set focus to it in the keypress event of the form (as well as the page's click and dblclick) as in the example above. I would like to do this without having unique code in every form's keypress and every page's click and dblclick(). There are a LOT of forms that meet this condition.
>>>
>>>All ideas appreciated!
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform