Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access Method
Message
From
21/12/2019 13:00:02
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01672305
Message ID:
01672388
Views:
49
>>>My textbox base class (in my application) has a property .BACK_COLOR_FOCUS (current has a value hard-coded). This property would have to be set to the value oApp.BACK_COLOR_FOCUS (Access method of the oApp class). But I cannot set it in the visual class. In a PRG class that would work.
>>
>>Here, this works (all in command window; curform.prg is on the path):
>>
create class testThomas as textbox of libs\ctls
>>ox=curform()
>>ox.AddProperty("backcolor_x","=goapp.bkcolor")   && next I saved the class and closed class editor
>>goapp=createobject("empty")
>>addproperty(goapp, "bkcolor", 32)
>>_screen.NewObject("oxx", "testthomas", "libs\ctls.vcx")
>>?_screen.oxx.backcolor_x
>>Here's curform.prg, which you can actually do in command window line by line:
>>
ASELOBJ(aa,1)
>>RETURN aa[1]
>>It doesn't really matter that there's a goapp.bkcolor_access method or not - I suggested having that method just for debugging, to see how many times it fires. The .bkcolor property (and other of your color properties) may as well be set in goApp.ReadConfig() method, or even hardcoded.
>
>Sorry for getting back to the technical discussion. My code now, with the change of the Function to Procedure works; but only in a PRG created Textbox class. Here is what I do:
>1. In the visual class TextBox (e.g. MyTextbox inherited from the VFP base textbox), I add a property .back_color_focus
>2. In this visual class I set the value of this property, .back_color_focus, to oApp.back_color_focus
>3. At run-time, when the base textbox class is instantiated, the Access method of the oApp (method oApp.back_color_focus_access) never fires. Therefore the value of the textbox property .back_color_focus remains empty.

Check the value of the .back_color_focus in the debugger. My bet is that it's a string containing "oApp.back_color_focus". In the editor (or in the halfbaked builder I used) you need to prefix the expression with an equal sign, which is instruction to runtime to treat the rest of the string as an expression. And then it should work as Thomas says, the expression is evaluated only once, on the first instantiation, as a property of the parent class. The rest of the instances of the same class should get a copy of the evaluated value (i.e. not the expression, but its value), which is the gist of Thomas's trick.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform