⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testunit1.pas

📁 Delphi中一直都没有能快速显示彩色文字信息的Memo控件而TRichEdit慢得无法在需要高速的场合使用
💻 PAS
字号:
unit TestUnit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, InfoMemo;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    InfoMemo1: TInfoMemo;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 with InfoMemo1 do begin
  MouseWheelVScrollSize := 3;
  TabSize := 2;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
AStr : string;
begin
 with InfoMemo1 do begin
  SetLineAttribute(1,1,14,clRed,clWhite,[fsItalic],False);
  SetLineAttribute(2,1,74,clGreen,clWhite,[],False);
  SetLineAttribute(3,1,74,clBlue,clWhite,[],False);
  SetLineAttribute(4,1,74,clRed,clWhite,[],False);
  SetLineAttribute(5,1,10,clGreen,clWhite,[],False);
  SetLineAttribute(6,1,74,clBlue,$00ACD6FF,[fsBold,fsUnderline],True);
  //
  AStr := 'Delphi中有一个线程类TThread是用来实现多线程编程,这个绝大多数Delphi书藉都有说到';
  for i := 1 to 30 do Lines.Add(AStr);
  SetLineAttribute(7,1,6,clRed,clWhite,[],False);
  SetLineAttribute(8,7,20,clBlue,clWhite,[],False);
  SetLineAttribute(9,7,27,clFuchsia,clWhite,[],False);
  SetLineAttribute(10,3,16,clRed,clWhite,[],False);
  SetLineAttribute(11,1,2,clMaroon,clWhite,[],False);
  SetLineAttribute(12,7,20,clBlue,clWhite,[],False);
  SetLineAttribute(13,28,33,clFuchsia,clWhite,[],False);
  SetLineAttribute(14,36,39,clBlue,clWhite,[],False);
  SetLineAttribute(15,50,61,clPurple,clWhite,[],False);
  SetLineAttribute(25,1,6,clRed,clWhite,[],True);
 end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -