你只能自画了,具体的高度长度要自己算一下,下面只是个示例var h:HDC; begin h := GetDC(RichEdit1.Handle); if h >0 then begin Self.Canvas.Handle := h; Canvas.Brush.Style := bsSolid; Canvas.Brush.Color := clRed; Self.Canvas.FillRect(Rect(0,0,50,50)); Self.Canvas.TextOut(0,0,'中华人民共和国'); end; end;
if ColorDialog2.execute then currtext.BackColor:=ColorDialog2.color;
h:HDC;
begin
h := GetDC(RichEdit1.Handle);
if h >0 then
begin
Self.Canvas.Handle := h;
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Self.Canvas.FillRect(Rect(0,0,50,50));
Self.Canvas.TextOut(0,0,'中华人民共和国');
end;
end;
currtext.BackColor:=ColorDialog2.color;
才搞懂你的意思。
你要求的是不大容易弄,得通过截获相应的消息处理吧。
不过,如果设个全局变量,也可能行。
当rxriched选择了文字时,可以设置背景色和文字色,当sellength=0时,再将设置改回来。