标签:
Passing Data Between Forms
FormData.dpr
---------------------------------------------------------
program FormData;
uses
Forms,
IWMain,
ServerController in ‘ServerController.pas‘ {IWServerController: TDataModule},
Main in ‘Main.pas‘ {formMain: TIWAppForm},
Dialog in ‘Dialog.pas‘ {formDialog: TIWAppForm};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TformIWMain, formIWMain);
Application.Run;
end.
Main.pas
----------------------------------------------
unit Main;
{PUBDIST}
interface
uses
IWAppForm, IWApplication, IWTypes, IWCompButton, IWCompEdit, Classes,
Controls, IWControl, IWCompLabel, Dialog, IWHTMLControls, IWBaseControl,
IWVCLBaseControl, IWBaseHTMLControl;
type
TformMain = class(TIWAppForm)
IWLabel1: TIWLabel;
editText: TIWEdit;
butnOk: TIWButton;
IWLink1: TIWLink;
procedure butnOkClick(Sender: TObject);
procedure IWAppFormCreate(Sender: TObject);
procedure IWLink1Click(Sender: TObject);
public
FDialogForm: TformDialog;
end;
implementation
{$R *.dfm}
uses
SysUtils;
procedure TformMain.butnOkClick(Sender: TObject);
var
s: string;
begin
s := Trim(editText.Text);
editText.Text := ‘‘;
if s = ‘‘ then begin
WebApplication.ShowMessage(‘Please enter some text.‘);
end else begin
with FDialogForm do begin
IWMemo1.Lines.Add(s);
Inc(FCount);
Show;
end;
end;
end;
procedure TformMain.IWAppFormCreate(Sender: TObject);
begin
FDialogForm := TformDialog.Create(WebApplication);
end;
procedure TformMain.IWLink1Click(Sender: TObject);
begin
WebApplication.Terminate(‘Good bye!‘);
end;
initialization
TformMain.SetAsMainForm;
end.
Dialog.pas
--------------------------------------------------------
unit Dialog;
{PUBDIST}
interface
uses
IWAppForm, IWApplication, IWTypes, IWHTMLControls, IWCompLabel, Classes,
Controls, IWControl, IWCompMemo, IWBaseControl, IWVCLBaseControl;
type
TformDialog = class(TIWAppForm)
IWMemo1: TIWMemo;
lablCount: TIWLabel;
linkReturn: TIWLink;
procedure linkReturnClick(Sender: TObject);
procedure IWAppFormRender(Sender: TObject);
public
FCount: Integer;
end;
implementation
{$R *.dfm}
uses
SysUtils;
procedure TformDialog.linkReturnClick(Sender: TObject);
begin
Hide;
end;
procedure TformDialog.IWAppFormRender(Sender: TObject);
begin
lablCount.Caption := ‘This form has been shown ‘ + IntToStr(FCount) + ‘ times.‘;
end;
end.
标签:
原文地址:http://www.cnblogs.com/missmd/p/4493351.html