Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping up with Control with Current Focus 1

Status
Not open for further replies.

white605

Technical User
Jan 20, 2003
394
US
Is there a way to add a property to a form that will always return the name of the control that the user has currently selected without using the gotfocus and lostfocus of each indivual control? I would like to Change the Backcolor of the current control programatically so users who cannot see the small insertion point or dotted lines around command buttons can immediatly identify where they are fixing to type or "try to type"
thanks
wjwjr
 
Hi!
Assumed that your are not using the native controls of VFP on your form but instead use subclassed controls from your library there is no need to place code in every control on the form.

Just put in your library the code you should have placed on the form in every control.

e.g. for a textbox in the gotfocus method :
this.backcolor = rgb(255,255,0)
and in the lostfocus method :
this.backcolor = rgb(255,255,255)

Be aware that if you are putting code in these method on the form that there must be reference to the code in the library as well.
e.g. on the form there is a control with code in the gotfocus method like:
=messagebox('this is a message from the gotfocus method')
than you MUST put also code like =dodefault() so the code from the gotfocus method in the library is executed as well.

Hope this helps.

-Bart
 
Thnaks for your reply, I am already doing that but was looking for the way foxpro keeps up with the "currently selected control" ie - the one with the dotted box around it showing that you are parked on it.
 

White,

I think you want the form's ActiveControl property. That will give you an object reference to the currently selected control.

If you want the control's name, use THISFORM.ActiveControl.Name.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
I just want to point out that if you're going to change the color of a control, the color you use shouldn't be hard-coded, but should be based on the user's Windows-level choices. Otherwise, you run the risk of making the field unreadable.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top