老是没加几行就出下面的错误,为什么啊?EoutOfResources with message RichEdit line insertion error

解决方案 »

  1.   

    整个代码如下:
    unit First;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Grids, ComCtrls,CustomizeDlg, ShellCtrls, ExtCtrls,richedit;type
      TForm1 = class(TForm)
        Label1: TLabel;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        RichEdit1: TRichEdit;
        RichEdit2: TRichEdit;
        procedure FormCreate(Sender: TObject);
        //procedure  HighlightText(Obj:  TRichEdit;  Row,  Col,  Len:  Integer);
        procedure Button1Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);  private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      Vt: array [1..8] of String;
      Expre: array [1..12] of String;
      i:integer;
    const
      compute: array [1..16,1..3]of integer=((7,11,3),(7,12,4),(6,9,1),(6,10,2),(5,7,5),(5,8,7),(4,5,3),(4,5,4),(4,6,8),(3,4,5),(3,4,7),(2,2,1),(2,2,2),(2,3,8),(1,1,5),(1,1,7));
      Vn: array [1..7] of String=('E','E’','T','T’','F','A','M');
    implementation
    uses finish,prematrix, ExpretoPic;
    {$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin
      RichEdit2.clear;
      RichEdit1.Clear;
      RichEdit2.Lines.Add('                            First集');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('E→TE′               {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('E′ →ATE′ | ε      {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('T→FT′               {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('T′ → MFT′ | ε     {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('F→ (E) ∣i           {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('A→+|-                 {  ');
      RichEdit2.Lines.Add('');
      RichEdit2.Lines.Add('M→*|/                {  ');
      Expre[1]:='E→TE′';
      Expre[2]:='E′ →ATE′';
      Expre[3]:='E′ →ε';
      Expre[4]:='T→FT′';
      Expre[5]:='T′ → MFT′';
      Expre[6]:='T′ →ε';
      Expre[7]:='F→ (E) ';
      Expre[8]:='F→i';
      Expre[9]:='A→+';
      Expre[10]:='A→-';
      Expre[11]:='M→*';
      Expre[12]:='M→/';
      Vt[1]:='+';
      Vt[2]:='-';
      Vt[3]:='*';
      Vt[4]:='/';
      Vt[5]:='(';
      Vt[6]:=')';
      Vt[7]:='i';
      Vt[8]:='e';  i:=1;
    end;
    procedure  HighlightText(Obj:  TRichEdit;  Row,  Col,  Len:  Integer);
    var  
       Fmt:  TCharFormat2;
       n:  Integer;
    begin
       Obj.SetFocus; 
       n  :=  SendMessage(Obj.Handle,  EM_LINEINDEX,  Row,  0)  +  Col;
       Obj.SelStart  :=  n;
       Obj.SelLength  :=  Len;              //  选中要高亮显示的文字
       Fmt.cbSize  :=  sizeof(Fmt);
       Fmt.dwMask  :=  CFM_COLOR  or  CFM_BACKCOLOR;
       SendMessage(Obj.Handle,  EM_GETCHARFORMAT,  SCF_SELECTION,  Integer(@Fmt));    //  获取文本信息
       Fmt.crTextColor  :=  not  Fmt.crTextColor  and  $FFFFFF;    //  颜色取反
       Fmt.crBackColor  :=  not  Fmt.crBackColor  and  $FFFFFF;    //  背景色取反
       SendMessage(Obj.Handle,  EM_SETCHARFORMAT,  SCF_SELECTION,  Integer(@Fmt));    //  设置
       //Obj.SelLength  :=  0;    //  取消选中文本
    end; 
    procedure TForm1.Button1Click(Sender: TObject);
    var
     pos,r:integer;
     temp:string;
    begin
      if(i<=16 ) then
      begin    RichEdit1.Lines.Add('利用规则:'+Expre[compute[i,2]]);
        RichEdit1.Lines.Add('First('+Vn[compute[i,1]]+')增加'+Vt[compute[i,3]]);    for r:=0 to compute[i,1]*2-1 do
        pos :=pos+ length(RichEdit2.Lines.Strings[r]) + 2;
        RichEdit2.selstart :=pos-2;
        RichEdit2.SetFocus;    temp:=RichEdit2.Lines.Strings[r]+' '+Vt[compute[i,3]]+',';
        RichEdit2.Lines.Delete(r);
        RichEdit2.Lines.Insert(r,temp);
        RichEdit2.Font.Color:=clred;
        i:=i+1;    HighlightText(RichEdit2,0,5,2);
      end
        else
           form2.showmodal;
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
      form4.showmodal;
    end;end.