Faceți căutări pe acest blog

duminică, 26 noiembrie 2017

"Typing" characters programatically (4)

As a practical application, here is a simple way to extract the content of an editbox, row by row

In the next demo, type whatever you want in the edit box, and click the form to see the "extraction" process

PUBLIC ofrm
ofrm = CREATEOBJECT("myform")
ofrm.show()

DEFINE CLASS myform as Form
 autocenter = .T.
 ADD OBJECT edt as myeditbox && addlinefeeds = .F. && successfully tested
 PROCEDURE click
  LOCAL lnStart,lnLen
  * keep the potential selection 
  lnStart = This.edt.SelStart
  lnSen = This.edt.SelLength
  * Jump to the beginning of editbox
  This.edt.keypress(1,2,.T.) &&CTRL+HOME
  DO WHILE .T.
   * go to the beginning of the row
   This.edt.keypress(1,0,.T.) && HOME
   * select to the end of the row
   This.edt.keypress(49,1,.T.) &&SHIFT+END
   * type the row content
   ACTIVATE SCREEN 
   ?This.edt.seltext
   * test if the task was completed
   IF This.edt.Selstart + This.edt.Sellength = LEN(This.edt.value)
    EXIT
   ENDIF
   *adwance to the next row
   This.edt.keypress(24,0,.T.) && DOWN ARROW
  ENDDO 
  * restore the selection
  This.edt.SelStart = m.lnStart 
  This.edt.SelLength = m.lnSen 
 ENDPROC
ENDDEFINE

DEFINE CLASS myeditbox as EditBox
 PROCEDURE keypress
  LPARAMETERS nkey,nshift,lraise
  IF m.lraise
   DODEFAULT(m.nkey,m.nshift)
   =This.Value
  ENDIF
 ENDPROC
ENDDEFINE 
 
Related links
[1] "Typing" characters programatically 
[2] "Typing" characters programatically (2) 
[3] "Typing" characters programatically (3) 

Niciun comentariu:

Trimiteți un comentariu