|
发表于 2009-3-5 13:05:32
|
显示全部楼层
There it is^__________________^
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TCharFormat2 fmt;
RichEdit1->Clear();
RichEdit1->Lines->Add(L"Line1");
RichEdit1->Lines->Add(L"Line2");
RichEdit1->Lines->Add(L"Line3");
int pos = 0;
int Tbl_TXTColor[]={clRed,clBlack,clBlue};
int Tbl_BGColor[]={clYellow,clGreen,clGray};
for(int i = 0 ; i < RichEdit1->Lines->Count ; i++)
{
RichEdit1->SelStart = pos;
RichEdit1->SelLength = RichEdit1->Lines->Strings.Length();
fmt.cbSize = sizeof(fmt);
fmt.dwMask = CFM_COLOR | CFM_BACKCOLOR;
fmt.crTextColor = Tbl_TXTColor;
fmt.crBackColor = Tbl_BGColor;
RichEdit1->Perform(EM_SETCHARFORMAT,SCF_SELECTION,int(&fmt));
pos += RichEdit1->SelLength+1;
}
RichEdit1->SelLength = 0;
} |
|