Hi Abb:
>A solution I got off the internet for that problem of the cursor not going
>to the 1st field after hitting an "Add" button (produced by the wizards,
>or me using Append Blank, or even in any examples from books that I have)
>was to add the following code to an Add button:
>ThisForm.Text1.SetFocus()
>Well, it doesn't work and I'm not surprised because the SetFocus() (don't
>laugh) didn't turn blue when I typed it. Having even searched the CD
>and not found SetFocus(), I don't think this solution applies VFP 5.
>Just out of curiosity, would the above worked VFP 3? What would be
>the VFP equivalent. You know, in the Tasmanian Traders, when you want
>to add something, the cursor _does_ go to the 1st field, but for the
>life of me, I haven't figured out how it does it yet!!!! Other than
>that, the damn thing is great!
OK, Abb. This is what I've learned:
"SetFocus is VFP's answer to the old _CUROBJ. It allows you to set the
focus to any control. SetFocus works kind of inside-out from the way
_CUROBJ does. With _CUROBJ, you assigned a value that leads to the
object you want. In the new OOP paradigm, you call the SetFocus method
for the object you want to receive focus." -- Dr. Tamar E. Granor
If you wish to manage the focus across pages, you can
"(1) make sure the focus goes to the right fields in the right order, and
(2) provide function key or hot key access (not a reference to other
products ) to the Save command and other necessary buttons. If you
have multiple page forms you must also (3) provide a mechanism for moving
the focus automatically from page to page.
"The normal behaviour of the focus on a page of a page frame is to cycle
around the _visible_ fields of the page and the form. The fields on
other pages are not visible, so they never get the focus. If you want
the last field of Page 1 to lead to the first field of Page 2, you need
to move the focus. The Valid method of the last field of each page can
contain the following code:
lnKey = LASTKEY()
IF lnKey != 15 AND lnKey != 19
IF thisform.Pageframe1.ActivePage < thisform.Pageframe1.PageCount
thisform.Pageframe1.ActivePage = thisform.Pageframe1.ActivePage + 1
ELSE
?? CHR(7)
thisform.cmdSave.SetFocus()
ENDI
ENDI
"You could make this program a method that you call from the Valid method
of each page's last field. This logic lets the user press Shift+Tab
(keycode=15) or the left arrow (keycode=19) to move backward out of the
final field, with no interference." -- Savannah Brentnall
Now these ladies know what they are talking about, but in 1648 pages of
VFP reference, this is all they had to say. Still, maybe it helps.
David in Dallas.
--- Maximus/2 3.01
---------------
* Origin: * MacSavvy OS/2 BBS * Dallas, Texas * 972-250-4479 * (1:124/1208)
|