有没有办法画Tmemo控件中不同行的背景色?

hehaa 2003-08-21 12:00:11
如:第1行红,第二行绿..等.
...全文
140 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
DWGZ 2003-08-22
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, RichEdit, RxRichEd;

type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
Button1: TButton;
RxRichEdit1: TRxRichEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var Fmt :TCharFormat2;
begin
FillChar(Fmt, SizeOf(TCharFormat2), 0);
Fmt.cbSize := SizeOf(TCharFormat2);
Fmt.dwMask := CFM_BACKCOLOR;
Fmt.crBackColor := ColorToRGB(clRed);
SendMessage(RichEdit1.Handle, EM_SETCHARFORMAT, SCF_ALL, LPARAM(@Fmt));
end;
hehaa 2003-08-22
  • 打赏
  • 举报
回复
to lxpbuaa(桂枝香在故国晚秋) :
我是要它背景变色...不是字体..有没有办法?

或者别的控件有吗?就是选中这一行时,背景变色..
hehaa 2003-08-22
  • 打赏
  • 举报
回复
RxRichEd...没有安装.............

不过我已经用画布画上去了...
bai11 2003-08-21
  • 打赏
  • 举报
回复
哪每一行的字呢?第一行红字,第二行绿字。。。。。。
lxpbuaa 2003-08-21
  • 打赏
  • 举报
回复
用TRichEdit,如:
begin
RichEdit1.SelStart := 0;
RichEdit1.SelLength := Length(RichEdit1.Lines[0]);
RichEdit1.SelAttributes.Color := clRed;
end;

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧