Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When for custom Controls
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00596595
Message ID:
00596606
Views:
24
>>>Hi everyone,
>>>
>>>I have a custom Control that I need to prevent access to under certain circumstances, however the control only appears to have a GotFocus and LostFocus not a When or Valid.
>>>
>>>Is there some way to reproduce the behaviour of the When method?
>>>
>>>Thanks in advance
>>
>>what about setting the controls 'enabled' property to 'FALSE'?
>>The user will not have 'access' to the control.
>>When the 'certain circumstance' occurs...
>>
>>THISFORM.Control.Enabled = .f.
>>
>>or
>>
>>THISFORM.Control.ReadONly = .t. is another way to limit user access to a control.....
>>
>>
>>i hope this helps...
>>if it does not...
>>... get more specific with your question..
>
>
>I guess that the real problem is that I can only test if they can access the control within the control ie what should be the When method.
>
>Any thoughts?

Caroline,

You could have some code in de GotFocus which determines whether access is allowed or not, and when not, skip to the next control (or back to the previous). Now note that this is some strange, because first you should have disabled the control, which will be dependend on something else. Now IMO this can be difficult anyway, because this will have to do with where you came from, and where you go to, and where the latter may be click on the concerning control, but may also be a control further down the line, underway triggering the Valid of the concerning control, and which may be unwanted.
To my own experience this always leads to never use the When at all, because you sort of get out of control. IOW, for reasons of decency, you'd again should provide for the disabling of the concerning control in advance.

However, it is is the control itself which determines the no-access-allowed, have you code in the GotFocus again.
Note that this is not an easy job, because of all kinds of anomalies you will encounter, but it surely can be done. But, better start with a general "GotFocusFunction", applicable to all other various kinds of controls you will have in future, because else you will find yourself having the code per type of control (checkbox, textbox etc). Call this function (PRG) from all the usual GotFocus methods.

My GotFocus function is around 7,000 lines of code (okay 5,000 is comments), also knowing it has to deal with recursiveness.

Maybe others have better ideas ...
Previous
Reply
Map
View

Click here to load this message in the networking platform