代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations } public
{ Public declarations }
end;var
Form1: TForm1;implementation
{$R *.dfm}procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Lpos,Cpos,LineLength:Longint;
begin
Lpos := SendMessage(Memo1.Handle,EM_LINEFROMCHAR,Memo1.SelStart,0);
Cpos := SendMessage(Memo1.Handle,EM_LINEINDEX,Lpos,0);
LineLength := SendMessage(Memo1.handle,EM_LINELENGTH,Cpos,0);
Cpos := Memo1.SelStart-CPos;
Label1.caption := '当前行值' + inttostr(Lpos);
Label2.caption := '字符位置' + inttostr(Cpos);
Label3.caption := '当前行字符总个数' + IntToStr(LineLength);
end;procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Lpos,Cpos,LineLength:Longint;
begin
Lpos := SendMessage(Memo1.Handle,EM_LINEFROMCHAR,Memo1.SelStart,0);
Cpos := SendMessage(Memo1.Handle,EM_LINEINDEX,Lpos,0);
LineLength := SendMessage(Memo1.handle,EM_LINELENGTH,Cpos,0);
Cpos := Memo1.SelStart-CPos;
Label1.caption := '当前行值' + inttostr(Lpos);
Label2.caption := '字符位置' + inttostr(Cpos);
Label3.caption := '当前行字符总个数' + IntToStr(LineLength);
end;end.可编译时出错:
[Error] Unit1.pas(39): Illegal character in input file: ' ' ($A1A1)
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations } public
{ Public declarations }
end;var
Form1: TForm1;implementation
{$R *.dfm}procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Lpos,Cpos,LineLength:Longint;
begin
Lpos := SendMessage(Memo1.Handle,EM_LINEFROMCHAR,Memo1.SelStart,0);
Cpos := SendMessage(Memo1.Handle,EM_LINEINDEX,Lpos,0);
LineLength := SendMessage(Memo1.handle,EM_LINELENGTH,Cpos,0);
Cpos := Memo1.SelStart-CPos;
Label1.caption := '当前行值' + inttostr(Lpos);
Label2.caption := '字符位置' + inttostr(Cpos);
Label3.caption := '当前行字符总个数' + IntToStr(LineLength);
end;procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Lpos,Cpos,LineLength:Longint;
begin
Lpos := SendMessage(Memo1.Handle,EM_LINEFROMCHAR,Memo1.SelStart,0);
Cpos := SendMessage(Memo1.Handle,EM_LINEINDEX,Lpos,0);
LineLength := SendMessage(Memo1.handle,EM_LINELENGTH,Cpos,0);
Cpos := Memo1.SelStart-CPos;
Label1.caption := '当前行值' + inttostr(Lpos);
Label2.caption := '字符位置' + inttostr(Cpos);
Label3.caption := '当前行字符总个数' + IntToStr(LineLength);
end;end.可编译时出错:
[Error] Unit1.pas(39): Illegal character in input file: ' ' ($A1A1)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货