Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transfer focus to previous control with focus after use
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00322283
Message ID:
00322333
Views:
22
>I'm not sure how WHEN helps me. How does WHEN give me the reference to the control 'passing' the focus? Could you further explain?

Control.GotFocus may be even better place to put the code.
* control.GotFocus()
thisform.navButtonClassContainer.LastControlUsed = this
***
>
>Is it possible to add the property to my navbutton class instead of the form to hold the object reference? I want to try to keep my classes as self contained and reliant as possible. If so, would this work?

Yes, you can add the .LastControlUsed property to your class.

*Button.Click()
* do some processing here
thisform.navButtonClassContainer.LastControlUsed.SetFocus()
***

Remember, if you use the property to hold the object reference do not forget to reset it to .NULL. before you close your form.

You can get away from this in you just store

thisform.navButtonClassContainer.LastControlName = this.Name
(The property now called LastControlName)

In this case you will not have the dangling object reference in any case, but you have to get the right name to address the last control then.
In simple case, assuming that all controls are on the form it may be be:

*Button.Click()
* do some processing here
local lcLastControlName
lcLastControlName = thisform.navButtonClassContainer.LastControlName
thisform.&lcLastControlName..SetFocus()
***

Of course there are other ways to do this.

HTH,

Nick
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