请问有没有对不同设置不同颜色的的仿RichEdit的控件? 请问有没有对不同设置不同颜色的的仿RichEdit的控件?在哪儿有下的,或那位大哥有能否发一个给我?先谢了是否在RichEdit中就可以对每行设置颜色?如果可以请教一下方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不好意思请问有没有对不同“行”设置不同颜色的的仿RichEdit的控件? 直接用RichEdit就可以了:uses RichEdit;procedure TForm1.SetLineColor(lineno: Integer; linecolor: TColor);var p: Integer; fmt: TCharFormat2;begin with RichEdit1 do begin p := Perform(EM_LINEINDEX, lineno, 0); SelStart := p; SelLength := Length(Lines[lineno]); fmt.cbSize := SizeOf(fmt); Fmt.dwMask := CFM_BACKCOLOR or CFM_WEIGHT; Fmt.crBackColor := linecolor; Perform(EM_SETCHARFORMAT, SCF_SELECTION, Integer(@fmt)); end;end;procedure TForm1.Button1Click(Sender: TObject);begin SetLineColor(0, clRed); // 设置第1行为红色end;需要2.0版本的Riched20.dll支持,Win2000自带,在98下的话可以把2000下的Riched20.dll拷过去覆盖。 以下将当前行变为红色: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; 再问:参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。 关于自定义combobox的问题。。。。。。。。。。。。。。。。。。。。。 给大家推荐一个暴强的网站,上去就知道怎么回事了~ THotKey的问题 怎样在image中将drawtext()写出的文字水平翻转? 查车牌的SQL语句 如何只关闭已打开的众多Word文档中的一个 这个进度条怎么写? 求救! 先给5分,答出给500分! 怎样在一台电脑上模拟在局域网或广域网上,用socket通讯的情况? 将Excel文件导入到dbgrid表后,为何只能显示float格式的数据?
请问有没有对不同“行”设置不同颜色的的仿RichEdit的控件?
var
p: Integer;
fmt: TCharFormat2;
begin
with RichEdit1 do begin
p := Perform(EM_LINEINDEX, lineno, 0);
SelStart := p;
SelLength := Length(Lines[lineno]);
fmt.cbSize := SizeOf(fmt);
Fmt.dwMask := CFM_BACKCOLOR or CFM_WEIGHT;
Fmt.crBackColor := linecolor;
Perform(EM_SETCHARFORMAT, SCF_SELECTION, Integer(@fmt));
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
SetLineColor(0, clRed); // 设置第1行为红色
end;需要2.0版本的Riched20.dll支持,Win2000自带,在98下的话可以把2000下的Riched20.dll拷过去覆盖。
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;