Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Regarding Tip: Control Valid() Fires Even When Read-Only
Message
De
25/04/2003 14:08:03
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00781549
Message ID:
00781610
Vues:
23
Don't forget that 'Return' only returns to the calling program - in your case, the descendent control calls the parent with DoDefault(), and the parent simply returns .T. to the caller.

What you want is:
If DoDefault()
  IF EMPTY(THIS.VALUE)
     RETURN .F.
   ENDIF
Endif
The problem, of course, is that this doesn't really make sense, since the 'DoDefault()' may have other code in it besides the 'ReadOnly' condition. If you know for certain that DoDefault() will only return .T. if the control is ReadOnly, and for no other reason, then this will work.

What would make more sense to me is this:
Local llRetVal
llRetVal = .T.
If !This.ReadOnly
  IF EMPTY(THIS.VALUE)
     llRetVal = .F.
  ENDIF
Endif

Return llRetVal
Alan

>In the May 2003 issue of the FoxPro Advisor there is a tip called "Control Valid() Fires Even When Read-Only." It made perfect sense so I added it to my base textbox class. My problem is how to handle the RETURN .T. in the base class so processing stops. In a subclassed textbox, I have DODEFAULT() to call the base class code but after the code runs, it still processes the code of the subclassed textbox.
>
>Example:
> txtBase.Valid()
>
>   **********************************************************************************
>   * Code from "Control Valid() Fires Even When Read-Only" - FoxPro Advisor, May 2003
>   **********************************************************************************
>   IF THIS.READONLY
>      RETURN .T.
>   ENDIF
>   **********************************************************************************
>
>   *  NOTE: If ReadOnly = .F., still returns .T.
>
>
> txtSubClass.Valid()
>
>   DODEFAULT()
>
>   * If the control is ReadOnly, I don't want this to occur!
>   IF EMPTY(THIS.VALUE)
>      RETURN .F.
>   ENDIF
>
>
>What's a common way to handle this?
>
>Thanks,
>Aaron
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform