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

📄 movestrings_mainform.pas

📁 source code for the Marco Cantu s book Delphi 2009 Handbook
💻 PAS
字号:
unit MoveStrings_MainForm;

interface

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

type
  TFormMoveStrings = class(TForm)
    Memo1: TMemo;
    btnMoveFailure: TButton;
    btnRowByte: TButton;
    procedure btnMoveFailureClick(Sender: TObject);
    procedure btnRowByteClick(Sender: TObject);
  private
    procedure Log (const strMsg: string);
  public
    { Public declarations }
  end;

var
  FormMoveStrings: TFormMoveStrings;

implementation

{$R *.dfm}

procedure TFormMoveStrings.btnMoveFailureClick(Sender: TObject);
var
  str1, str2: string;
  buffer: TBytes;
begin
  str1 := 'Hello world';

  SetLength (buffer, Length (str1));
  Move (str1[1], buffer[1], Length (str1));

  SetLength (str2, Length (buffer));
  Move (buffer[1], str2[1], Length (buffer));

  Log (str1 + ' becomes ' + str2);
end;

procedure TFormMoveStrings.btnRowByteClick(Sender: TObject);
var
  str1, str2: RawByteString;
  buffer: TBytes;
begin
  str1 := 'Hello world';

  SetLength (buffer, Length (str1));
  Move (str1[1], buffer[1], Length (str1));

  SetLength (str2, Length (buffer));
  Move (buffer[1], str2[1], Length (buffer));

  Log (str1 + ' becomes ' + str2);
end;

procedure TFormMoveStrings.Log(const strMsg: string);
begin
  Memo1.Lines.Add (strMsg);
end;

end.

⌨️ 快捷键说明

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