i have been toying with the idea of mimicking ms outlook's way of handling email addresses being keyed-in in the to, cc and bcc entry fields. here is my take on that:

public oform1

oform1=newobject("form1")
oform1.show return ************************************************** *-- form: form1 (c:\temp\form1.scx) *-- parentclass: form *-- baseclass: form *-- time stamp: 06/06/08 09:55:13 am * define class form1 as form top = 0 left = 0 height = 128 width = 482 docreate = .t.
caption = "form1" name = "form1" add object text1 as textbox with ;
fontname = "verdana", ;
fontsize = 8, ;
height = 21, ;
left = 12, ;
top = 24, ;
width = 458, ;
name = "text1" add object edit1 as editbox with ;
fontname = "verdana", ;
fontsize = 8, ;
height = 49, ;
left = 12, ;
top = 60, ;
width = 459, ;
name = "edit1" procedure _selectaddr
lparameters ocontrol

local csep,ctext,ncntsep,nselfr,;
lnx,lny,nfr,nto,nsellen,nadd
local array apos(1)

csep = ";" ctext = alltrim(ocontrol.value)
ncntsep = occurs(csep,ctext)
nselfr = ocontrol.selstart dimension apos(ncntsep+1)
apos(1) = 0 for lnx = 2 to ncntsep+1)
apos(lnx) = at(csep,ocontrol.value,lnx-1)
next if right(ctext,1) <> csep
nadd = alen(apos,1)+1 dimension apos(nadd)
apos(nadd) = len(ctext)
endif nfr = 0 nto = 0 for lny = 1 to alen(apos,1)
if apos(lny) <= nselfr
nfr = apos(lny)
endif if apos(lny) >= nselfr and nto = 0 nto = apos(lny) endif next nsellen = nto - nfr with ocontrol
.selstart = nfr
.sellength = iif(nsellen<=0,1,nsellen)
endwith endproc procedure init * sample email addresses in textbox and editbox with this .text1.value = "myemail@company.com.sg;customer@sales.com;erik@gomex.com" .edit1.value = "myemail@company.com.sg;customer@sales.com;erik@gomex.com" endwith endproc procedure text1.click this.parent._selectaddr(this)
endproc procedure edit1.click this.parent._selectaddr(this)
endproc enddefine * *-- enddefine: form1 **************************************************

feedbacks are always welcome. please feel free to use and improve the above code.

Leave a Reply

Your email address will not be published. Required fields are marked *