Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access Method
Message
 
 
To
21/12/2019 09:16:52
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01672305
Message ID:
01672372
Views:
56
>>>>My actual case is different than the example in the initial message. The initial message of the thread had an example of making the textbox background color customizable by user. Your approach - not the Access method - but the fact that some other class can get the custom version, one time, is very helpful. So, for that I thank you very much. Let me describe the actual case:
>>>>My textbox have a code in the method GotFocus where the background color is set to a different color. That is, when a user clicks on a textbox, the backcolor changes to a distinct color. This distinct color is hardcoded in a property of the base textbox class. When a user leaves the textbox, the backcolor changes back to default.
>>>>Now, I won't have to use this hard-coded approach; but rather read a value from a configuration file - ONE TIME AT THE TOP OF APPLICATION - and set the value to the property of the application object (property TEXT_BCOLOR_FOCUS). Then the value in this property will be used in all textboxes. Since reading of an external configuration file will be necessary only one time speed will be quite adequate.
>>>
>>>And Thomas's trick will serve exactly the same. You set goapp.backcolor and other predefined colors by reading a config instead of hardcoding a color. That's the only difference.
>>>
>>>Using his method, when you instantiate any of these textboxes, there are no method calls, no code in the init. It's only these color properties which have goApp.someColor as values - which will be referenced only the first time; the other instances of the same class will inherit the value as it is, without referencing goApp.someColor again. Which is weird and I haven't tested it yet, but I trus Thomas did. There's a simple way to check this - have a goapp.someColor_access method call aStack() function and log its contents. If he's right, there should be just one call (per class, that is), not one for each instance.
>>
>>In order for Thomas' approach with Access to work, I would need to have the textbox base class created in code. Since in my case the base class is created visually, I can't figure out (without hacking the vcx file) how to set a property of a base class to the value in the oApp class. Here is more details:
>>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.
>
>I don't see any reason why this shouldn't work with a visual class. I haven't studied Thomas' solution, but please explain what's the specific problem you mention.

Here is an example I tried (that did't work).
I created a method TEXT_BACK_COLOR_FOCUS_ACCESS() in the oApp class.
Then in the base textbox class (in the visual designer) I set the value of a property BACK_COLOR_FOCUS to oApp.TEST_BACK_COLOR_FOCUS
But at run-time the method TEXT_BACK_COLOR_FOCUS_ACCESS() never fires.
Let me know what you see I am doing wrong.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform