Hi!
Ok, so now code changes. Try this:
if empty(this.When())
this.SetAll('Enabled',.F.)
else
this.SetAll('Enabled',.T.)
endif
This should for sure move focus out of control, because all elements are disabled inside of the custom control, so nothing canget focus at all.
>Correct and it always seems to run the controls GotFocus.
>
>>Hi!
>>
>>Did you meant that nodefault did not work for custom control? Strange, though not so much - because there is a GotFocus also for controls inside of the custom contol...
>>
>>>Thanks Vlad that is exactly what I was after I will try it again as before I was unable to get a nodefault to work!
>>>
>>>>Hi!
>>>>
>>>>Add When method to the control and put the code in the GotFocus event:
>>>>
>>>>if empty(this.When())
>>>> this.enabled=.F.
>>>>else
>>>> this.enabled=.T.
>>>>endif
>>>>
>>>>
>>>>So whenever you use this class, When event will be still available.
>>>>
>>>>BTW, if you do nto want to disable control when it has no access, but just disable the access, you can do following in GotFocus event:
>>>>
>>>>
>>>>if empty(this.When())
>>>> nodefault
>>>>endif
>>>>
>>>>
>>>>Nodefault command in GotFocus event prevent control to get focus.
>>>>
>>>>HTH.
>>>>
>>>>>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
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.