MS Outlook To, Cc and Bcc Entry Fields when composing emails
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.