unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
procedure ButtonClick(Sender: TObject);
private
{ Private declarations }
public
sResultString : String;
{ Public declarations }
end;
var
Form2: TForm2;
Function ShowInputBox() : string;
implementation
{$R *.DFM}
Function ShowInputBox() : string;
begin
with Tform2.Create(nil) do
begin
try
sResultString := '';
showmodal;
result := sResultString;
finally
free;
end;
end;
end;
procedure TForm2.ButtonClick(Sender: TObject);
begin
if Sender is TButton then
sResultString := sResultString + (Sender as TButton).caption;
end;
end.
unit Unit1;//测试
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Myedit;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text:=ShowInputBox();
end;
end.