> > Is it because you haven't explicitly set the FrmCapture variable, and
you
> > are using it in your showmodal procedure?
> > ie) FrmCapture := TFrmCapture.Create(Application);
> Jeepers, have a cigar, and I get the dummy of the week award.
> Make it:
> with TfrmCapture.Create(Application) do
> try
> ShowModal;
> finally
> frmcapture.Free;
> end;
No! This is not correct
the statement:
with TfrmCapture.Create(application) do try
Showmodal; // This shows the newly created form
finally
frmCapture.Free; // This frees a previously created form NOT the new
one.
end;
does not assign an object to 'frmCapture'
the following would:
frmCaption := TfrmCapture.Create(Application);
with frmcapture do try
ShowModal;
finally
Release; // Really should use the release procedure for forms
end;
The question really is - Why do you want to use the handle frmcapture at all
when the following is perfectly correct.
with TFrmCapture.create(nil) do try
ShowModal;
finally
Release;
end;
Remember that in 'var x :TObject'. x is not the object itself but a pointer
to an
object.
procedure TForm1.Button1OnClick(Sender :Tobject);
var
A,B :Tbutton;
begin
A := Tbutton.Create(self);
A.Parent := self;
A.Caption := 'Spam A';
B := A;
B.Caption := 'Spam B';
end;
notice that only one button is created but 2 variable 'refer' to it.
now this is an example of what your code is doing
procedure TForm1.Button1OnClick(Sender :Tobject);
var
button :Tbutton;
begin
button := TButton.Create(self);
button.Parent := self;
button.caption := 'Button Caption';
with TButton.Create(self) do try
Parent := self;
caption := 'Unnamed Button';
finally
button.free;
end;
end;
You'll see when you run it that the unnamed button is not freed
but the first one was.
--
Aaron@home
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz