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:56:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/08/2006 08:51:30
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01142937
Message ID:
01142950
Views:
9
This message has been marked as the solution to the initial question of the thread.
This works for me:
Public oForm
oForm=Createobject('MyForm')
oForm.Show()

Function Translate(tcCaption)
  Return Proper(m.tcCaption)+'BindEventTranslator'

Define Class myForm As Form
  Add Object lbl1 As Label With Left=10,Top=10,AutoSize=.T.,Caption="mylabel1"
  Add Object lbl2 As Label With Left=10,Top=40,AutoSize=.T.,Caption="mylabel2"
  Add Object lbl3 As Label With Left=10,Top=70,AutoSize=.T.,Caption="mylabel3"

  Add Object cmdChangeCaptions As CommandButton ;
    WITH Left=10,Top=100,AutoSize=.T.,Caption="Change"

  Procedure Init
    This.AddProperty("oTranslateTools", Newobject('TranslateTools'))
    For Each oControl In This.Controls
      If Lower(oControl.BaseClass) == 'label'
        Bindevent(oControl, "Caption", This.oTranslateTools, "Translater",1)
      Endif
    Endfor
  Endproc

  Procedure cmdChangeCaptions.Click
    With Thisform
      .lbl1.Caption = 'newlabel1'
      .lbl2.Caption = 'newlabel2'
      .lbl3.Caption = 'newlabel3'
    Endwith
  Endproc
Enddefine


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
enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform