Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use BINDEVENT to intercept dynamic caption changes
Message
From
04/08/2006 08:25:00
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Use BINDEVENT to intercept dynamic caption changes
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01142937
Message ID:
01142937
Views:
73
I am attempting to implement a simple mechanism to translate application UI into other languages. The mechanism so far works fine on static captions (labels, checkboxes, radio buttons etc).

However, I would like to use BINDEVENTS to capture when a caption is changed programmatically, and replace the assigned caption with a translated version. The problem is that the caption is momentarily assigned the new translation, but then reverts to the untranslated version. The flag parameter of BINDEVENTS seems to offer ways of controlling this behaviour for events (ie triggering the delegate after the event), but the flags do not seem to affect the setting of properties.

Overall, a better approach would probably have been to have subclassed all labels and then use an assign method, but as this would require substantial reengineering, I would prefer something that could be carried dynamically.

I use the following command to create the binding:
BINDEVENT(m.tmpSrc, "Caption", oTranslateTools, "Translater")
And the following class to intercept the caption change and replace with a translated version:
DEFINE CLASS TranslateTools AS Custom

PROCEDURE Translater

	*	Get the object raising the event
	LOCAL ARRAY EventArray(1)
	AEVENTS(EventArray, 0)
	oCtrl = EventArray(1)

	oCtrl.Caption = Translate(oCtrl.Caption)

ENDPROC
However as soon as the translater procedure returns, the caption reverts.

Any ideas?
Next
Reply
Map
View

Click here to load this message in the networking platform