主页 > 编程资料 > Delphi >
发布时间:2015-09-22 作者:网络 阅读:166次

本例效果图:



代码文件:
unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    Memo1: TMemo;    Button1: TButton;    Edit1: TEdit;    procedure FormCreate(Sender: TObject);    procedure Button1Click(Sender: TObject);    procedure Memo1Click(Sender: TObject);  end;var  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var  str: string;  pcw: PWideChar;  cw: WideChar;  i: Integer;begin  Memo1.Clear;  str := Edit1.Text;  pcw := PWideChar(str);  for i := 0 to StrLen(pcw) - 1 do  begin    cw := (pcw+i)^;    Memo1.Lines.Add(Format('$%.4x', [Ord(cw)]));    //Memo1.Lines.Add(Format('$%.4x', [Ord(str[i+1])])); {也可以用这句替换上面两行}  end;end;procedure TForm1.FormCreate(Sender: TObject);begin  Memo1.Clear;  Memo1.Align := alLeft;  Memo1.ScrollBars := ssVertical;end;procedure TForm1.Memo1Click(Sender: TObject);var  str: string;begin  str := Memo1.Lines[Memo1.CaretPos.Y];  Text := WideChar(StrToIntDef(str, 0));end;end.

关键字词: