Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ThisForm.FirstObject.SetFocus
Message
From
16/11/2001 16:45:13
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00582940
Message ID:
00583002
Views:
35
This message has been marked as a message which has helped to the initial question of the thread.
>J. Crescencio,
>
>>>> You don't need to. Just set the tabindex property
>>>> of the control(s). The lowest TabIndex setting will
>>>> have the focus when the form is activated.
>
>I have to do this because this form is inside a FormSet. Then I have to control this Form with Form.Visible = .T. / .F. - Then, when I have to know the firstobject because the second time that I do Form.Visible = .T., the cursor is in the object that the last time...
>
>I create one propertie, where I type the name of object, then I can do SetFocus... but maybe, VFP makes it easier! :)
>
>Sorry about my English... :)
>
>[]'s

OK, I understand. The way you would go back to the first control is by coding the setfocus on the form's activate. To find out the first control you would loop the form's controls array (you can treat it as a collection) and find out the lower Tabindex value. You can save the name of this control to a form's property and .Setfocus to it on the form's activate event.

But it wouldn't be much different than what you are doing now, other than being evaluated at runtime instead of a hard coded control name.

Something like this:
	procedure init
		Local lnIndex
		lnIndex = 1000
		For Each oCtl in This.Controls
			If oCtl.TabIndex < lnIndex
				lnIndex = oCtl.TabIndex
				This.FirstControl = oCtl.Name
			Endif
		Next
	endproc

	procedure activate
		Local lFirst
		lFirst = Eval("This." + This.FirstControl)
		lFirst.SetFocus
	endproc
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform