Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing controls with setfocus()
Message
From
25/08/2008 00:27:08
 
 
To
24/08/2008 23:55:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01341355
Message ID:
01341435
Views:
19
>>>>Your suggested approach is quite similar to what I had started trying. The key from your post was that there is no magic bullet solution, so you got me back to work on the problem. It’s working now, and here’s what I ended up with:
>>>>
>>>>A global (public) variable gcCameFrom
>>>>
>>>>For each txtBox, or other control, that changed the grid’s RecordSource content
>>>>In GotFocus()
gcCameFrom = This.Name
>>>
>>>Except that this.name is relative to .parent; if you have instantiated a same composite class several places - say, a container with two or three textboxes to enter phone number, area code, internat country code etc - the members of that container will have the same names in every instance, names you can't change.
>>>
>>>I'd suggest
gcCameFrom=sys(1272, this)
>>>
>>>which would give you full hierarchy, or even
>>>
>>>
goCameFrom=this
>>>
>>>as a direct object reference, but in that case you'd have to make sure you clear that when your form loses focus.
>>
>>Dragan
>>Using "this" was my initial approach, but I couldn't figure out how to use it to setfocus. With gcCameFrom = this.name ... I use
with thisform
>>.&gcCamefrom..setFocus()
but this syntax doesn't work with goCameFrom = this when I use ...
with thisform
>>.&goCameFrom..setfocus()
>>I get a syntax error. What would be the right syntax to do a setfocus() for goCameFrom?
>
>You should have observed the contents of gcCameFrom - my guess is that the first segment, i.e. the top level object, is the name of your form plus a digit 1, something like myform1.pageframe1.page2. etc etc. You could remove that first segment, and leave that first dot and everything after it, then &gocamefrom..whatever() would work.
>
>If you have an object reference, it behaves the same as the object itself, i.e. all references to the same object work the same. So if you assigned This to something, whatever you do with This you can do with this other variable or property or array element or collection item - they differ only in scope. So...
>
>goCameFrom.SetFocus()
>
>without any macros. Remember to release the reference - look up garbage collection on Fox Wiki - somewhere (form.deactivate() perhaps), goCameFrom=null will do that.

Thanks for the explainations. It's so obvious now that I have the answer. I have now implimented and tested both the gcCameFrom = sys(1272, this) approach (with the formname. striped out) and the goCameFrom = this approach. Both work fine. Thanks.

Bob
Previous
Reply
Map
View

Click here to load this message in the networking platform