Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I make an edit box scroll down through code?
Message
 
 
À
29/12/1999 23:04:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00309915
Message ID:
00310373
Vues:
31
Albert,

Thanks for the class, now it's better.
Anyway, I'm going to design my own new classes for users input. I'm starting today, I have a basic idea, how to do it, but few teh. questions may be problematic.

>Mike's insight into the behavior of the SelStart property fixes the quirky cursor positioning in my editbox code. Try this:
>
>
>oForm = createobject("TestForm")
>oForm.visible = .t.
>read events
>
>define class TestForm as form
>  add object edtValidated as ValidatedEditbox
>  procedure QueryUnload
>    clear events
>  endproc
>enddefine
>
>define class ZipValidator as custom
>
>  DigitCount = 5
>
>  function Init
>    lparameters tnDigitCount
>
>    if vartype( tnDigitCount ) = 'N'
>      this.DigitCount = tnDigitCount
>    endif
>  endfunc
>
>  function ValidateString
>    lparameters tcString
>
>    local array laString[1]
>    local i, lnLineCount, lnValue
>
>    if vartype( tcString ) = 'C'
>      lnLineCount = alines( laString, tcString, .t. )
>      tcString = ""
>      for i = 1 to lnLineCount
>        if !empty( laString[i] )
>          laString[i] = transform( int( val( laString[i] ) ) )
>          * padr() is used because you are formatting ZIP Codes
>          laString[i] = padr( laString[i], this.DigitCount, '0' )
>          tcString = tcString + laString[i] + chr(13)
>        endif
>      endfor
>    endif
>
>    return tcString
>
>  endfunc
>
>enddefine
>
>define class ValidatedEditbox as editbox
>
>  * default validator, for some reason createobject() won't work here
>  Validator = null
>
>  function Init
>    lparameters toValidator
>
>    * we are using deligation for the validator
>    if vartype( toValidator ) = 'O'
>      this.Validator = toValidator
>    else
>      this.Validator = createobject( "ZipValidator" )
>    endif
>  endfunc
>
>  procedure InteractiveChange
>    * thanks to Mike Helland for his info on SelStart cursor positioning
>    local lnSelStart
>    lnSelStart = this.selstart
>    this.value = this.Validator.ValidateString( this.value )
>    this.selstart = lnSelStart
>  endproc
>
>enddefine
>
>
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform