On 02-01-97 21:58, Abb Naklie was heard to bellow to David Powell
about SETFOCUS().
AN> A solution I got off the internet for that problem of the cursor not
AN> going to the 1st field after hitting an "Add" button (produced by the
AN> wizards, or me using Append Blank, or even in any examples from books
AN> that I have) was to add the following code to an Add button:
AN> ThisForm.Text1.SetFocus()
Hi Abb. Pardon me for jumping in here. I am still learning this stuff
but your question intrigued me so I looked a couple of things up. I believe
the
example you got above was intended to be generic where "Text1" is the name of
the field where you want to set focus. The help in VFP5 gives the format
of the setfocus command as control.SetFocus. Thus, if you want your Customer
Name field (say CustNAme) to get the focus you would say CustName.SetFocus()
AN> Well, it doesn't work and I'm not surprised because the SetFocus()
AN> (don't laugh) didn't turn blue when I typed it. Having even searched
AN> the CD and not found SetFocus(), I don't think this solution applies
AN> VFP 5. Just out of curiosity, would the above worked VFP 3? What would
AN> be the VFP equivalent. You know, in the Tasmanian Traders, when you
AN> want to add something, the cursor _does_ go to the 1st field, but for
AN> the life of me, I haven't figured out how it does it yet!!!! Other
AN> than that, the damn thing is great!
In Tasmanian Traders if you open the tastrade project and go to
classes, under tsbase classes you will find tstoolbar. If you modify
tstoolbar,
click on the add button and bring up code using the right click, you will
see a procedure called Addnew. Now under tsbaseform, they define addnew
which does a buch of stuff. The Key however is under each form. If you
go to the Customer form for example and bring up the Code area and go to
the form section you will find the addform procedure. This procedure is
modified to call the default operations from the base form class and then
you will see the command that places focus on the first field -
Thisform.pageframes.page1.cntCustomerInfo.txtCustomer_ID.SetFocus()
which is juat a more specific definition but the same as the one I gave above
in layout. They do it this way because the SetFocus, I believe, has to name
a specific field in each form. I hope I am being clear and this helps
because, as I said, I am still learning this object oriented approach.
- Bruce -
... Your E-Mail has been returned due to insufficient voltage.
___ Blue Wave/QWK v2.12
--- PCBoard 15.2
(1:134/10)
---------------
* Origin: 32 lines 40 Gig BBS, Realtime InterNet SLIP (403)247-7900
|