6
631229
Unregistered / Unconfirmed
GUEST, unregistred user!
我有两个窗体,Form1和MainForm,希望程序运行时先弹出封面窗体Form1,显示欢迎信息并
要求输入几个全局变量,然后就再也不用它了,即希望释放掉它所占的内存等所有资源,然
后显示主窗口MainForm。为此在Project-> Options中设MainForm为主窗体,将Form1移
至Available Forms列表中。项目文件代码如下:
program Activity;
uses
Forms,
Main in 'MAIN.PAS' {MainForm},
Cover in 'Cover.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
With TForm1.Create(nil) do
try
Showmodal;
Update;
finally
Free;
end;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
Form1窗体的代码如下:
unit Cover;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CentroidLongtitude,CentroidLatitude:Single;
UpLeftLongtitude,UpRightLongtitude,DownLeftLatitude,DownRightLatitude:Single;
implementation
uses Main;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
while (Edit1.text<>'') And (Edit2.text<>'') And (Edit3.text<>'') And (Edit4.text<>'') Do
begin
CentroidLongtitude:=StrToInt(Edit1.text)+(StrToFloat(Edit2.text))/60;
CentroidLatitude:=StrToInt(Edit3.text)+(StrToFloat(Edit4.text))/60;
UpLeftLongtitude:=CentroidLongtitude+1.4;
UpRightLongtitude:=CentroidLongtitude+1.4;
DownLeftLatitude:=CentroidLatitude+1.4;
DownRightLatitude:=CentroidLatitude+1.4;
end;
end;
end.
问题是:Form1出现后如果直接关闭它,可以顺利地出现主窗体MainForm,但如果在Form1里的
Edit1、Edit2、Edit3、Edit4等里输入数值后单击Button1,主窗体就出不来运行不下去了。
将项目文件代码中的Free改写成TForm1.Button1Click(Sender: TObject中的
DownRightLatitude:=CentroidLatitude+1.4后的Form1.free也不行。
哪位大侠能帮我解决这个问题,除给分外,我还可以告诉他一个免费的Gis控件下载地址。
要求输入几个全局变量,然后就再也不用它了,即希望释放掉它所占的内存等所有资源,然
后显示主窗口MainForm。为此在Project-> Options中设MainForm为主窗体,将Form1移
至Available Forms列表中。项目文件代码如下:
program Activity;
uses
Forms,
Main in 'MAIN.PAS' {MainForm},
Cover in 'Cover.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
With TForm1.Create(nil) do
try
Showmodal;
Update;
finally
Free;
end;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
Form1窗体的代码如下:
unit Cover;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CentroidLongtitude,CentroidLatitude:Single;
UpLeftLongtitude,UpRightLongtitude,DownLeftLatitude,DownRightLatitude:Single;
implementation
uses Main;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
while (Edit1.text<>'') And (Edit2.text<>'') And (Edit3.text<>'') And (Edit4.text<>'') Do
begin
CentroidLongtitude:=StrToInt(Edit1.text)+(StrToFloat(Edit2.text))/60;
CentroidLatitude:=StrToInt(Edit3.text)+(StrToFloat(Edit4.text))/60;
UpLeftLongtitude:=CentroidLongtitude+1.4;
UpRightLongtitude:=CentroidLongtitude+1.4;
DownLeftLatitude:=CentroidLatitude+1.4;
DownRightLatitude:=CentroidLatitude+1.4;
end;
end;
end.
问题是:Form1出现后如果直接关闭它,可以顺利地出现主窗体MainForm,但如果在Form1里的
Edit1、Edit2、Edit3、Edit4等里输入数值后单击Button1,主窗体就出不来运行不下去了。
将项目文件代码中的Free改写成TForm1.Button1Click(Sender: TObject中的
DownRightLatitude:=CentroidLatitude+1.4后的Form1.free也不行。
哪位大侠能帮我解决这个问题,除给分外,我还可以告诉他一个免费的Gis控件下载地址。