Try the next code: It works fine (I tested it)
program Q_21039479;
uses
Forms,
Unit1_Q_21039479 in 'Unit1_Q_21039479.pas' {Form1},
Unit2_Q_21039479 in 'Unit2_Q_21039479.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TFo
Application.CreateForm(TFo
Application.Run;
end.
//........ Unit1
unit Unit1_Q_21039479;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private{ Private declarations }
public { Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2_Q_21039479;
{$R *.dfm}
procedure TForm1.Button1Click(Sender
begin
Form2.Show;
end;
end.
//........ Form1
object Form1: TForm1
Left = 224
Top = 128
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poDefaultPosOnly
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 8
Top = 8
Width = 96
Height = 25
Caption = 'Show Form2'
TabOrder = 0
OnClick = Button1Click
end
end
//........ Unit2
unit Unit2_Q_21039479;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm2 = class(TForm)
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private{ Private declarations }
public { Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
begin
Timer1.Enabled := True;
end;
procedure TForm2.Timer1Timer(Sender:
begin
Hide;
end;
end.
//........ Form2
object Form2: TForm2
Left = 288
Top = 160
Width = 512
Height = 320
Caption = 'Form2'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Timer1: TTimer
Enabled = False
Interval = 3000
OnTimer = Timer1Timer
Left = 16
Top = 16
end
end
//........
emil
Main Topics
Browse All Topics





by: KyleyHarrisPosted on 2004-06-27 at 07:23:15ID: 11409959
It is a bug. Probably in windows. Why does Form2 need to stay in memory.
TObject);
: TObject);
procedure TForm1.Timer1Timer(Sender:
begin
FForm2.Release;
FForm2 := nil;
Timer1.Enabled := false;
end;
procedure TForm1.Button1Click(Sender
begin
FForm2 := TForm2.Create(Self);
FForm2.Show;
Timer1.Enabled := true;
end;
this way you'll not have a problem because the form will only exist for the period that you need it. If you need the form2 to stay in memory because it is processing data then I would reccommend that you move all your business logic into a non-visual object that resides on the Form1 of the example. Make Form2 a view and pass the business object to it for use during its 3-second life..