请在DELPHI中怎么样改变RICHEDIT某一行文字的字体和颜色(20分)

  • 主题发起人 huaweinet
  • 开始时间
H

huaweinet

Unregistered / Unconfirmed
GUEST, unregistred user!
请在DELPHI中怎么样改变RICHEDIT某一行文字的字体和颜色
 
以下将当前行变为红色:
procedure TForm1.Button1Click(Sender: TObject);
var
x1,y1,x,y:integer;
begin
with richedit1 do
begin
x1:=selstart;
y1:=selLength;
Y := SendMessage(Handle, EM_EXLINEFROMCHAR, 0,SelStart);
X := (SelStart - SendMessage(Handle, EM_LINEINDEX,Y, 0));
SelStart :=x1-x;
Sellength :=Length(lines[y]);
SelAttributes.size :=20;
SelAttributes.color :=clRed;
SelAttributes.name :='宋体';
SelStart :=x1;
Sellength :=y1;
HideSelection :=false;
end;
end;
 
顶部