在输入英文时能正确有将打错的字的Color改为红色。但在输入中文里却不能正确有比较???请帮我看一看下面的代码:
var
Form1: TForm1;
ModifyLength:Integer;
procedure TForm1.RichEdit1Change(Sender: TObject);
var
i:Integer;
x,y:String;
begin
i:=Length(Richedit1.Text );
RichEdit1.SelStart :=ModifyLength;
RichEdit1.SelLength :=i-ModifyLength;
x:=Copy(Line1.Caption ,ModifyLength-1,i-ModifyLength);
y:=RichEdit1.SelText;
if x<>y then //在这里为什么处理中文时没有更改呢???
RichEdit1.SelAttributes.Color:=Clred;
RichEdit1.SelStart :=i; //取消当前的选择不知用什么就用这一句代替了
RichEDit1.SelAttributes.Color :=Cllime;
end;
procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
ModifyLength:=Length(RichEdit1.Text ); //应取得字符的开始位置
if Length(Line1.Caption)<=Length(RichEdit1.Text)-2 then
RichEdit2.SetFocus;
if (key=8) then
key:=0;
end;