Board index » delphi » Call Form in runtime

Call Form in runtime


2006-04-17 06:39:14 AM
delphi241
Hi,
I have a small problem with calling form in runtime!
If I have a procedure or function
ProcedureX( Form: TForm)
How can I pass a parameter Form into procedure if I only know a name of
the form?
Thanks ... ;o)
--
regards,
sasa mihajlovic
XXXX@XXXXX.COM
www.msdinfo.com
 
 

Re:Call Form in runtime

I am not sure that I understand what you are trying to do. Have you
created a form instance and you want to pass that instance to a
procedure? If so, try the following. If not, please explain what you
want to do.
var
AForm: TAForm;
begin
AForm := TAForm.Create(Self);
MyProc(AForm);
where MyProc is declared as:
procedure MyProc(SomeForm: TForm)
begin
...
end;
--
Bill Todd (TeamB)
 

Re:Call Form in runtime

Hi bil,
Simply. I have a function which is have a form type as a parameter! I
mean on a form that is exist into project!
For example:
PaxScript have an procedure AddForm( Form: TForm) and when I want to
use all public properties of this form into runtime scripting I must
pass the name of the form which I want to use at this moment! I can use
for this sample Screen.ActiveForm, but I have a cases when I know jus a
name of the form and I must pass TForm parameter to a procedure by
form's name!
I think that will help you to understand a problem! :D
--
regards,
sasa mihajlovic
XXXX@XXXXX.COM
www.msdinfo.com
 

Re:Call Form in runtime

sasa mihajlovic writes:
Quote
Hi bil,

Simply. I have a function which is have a form type as a parameter! I
mean on a form that is exist into project!

For example:

PaxScript have an procedure AddForm( Form: TForm) and when I want to
use all public properties of this form into runtime scripting I must
pass the name of the form which I want to use at this moment! I can
use for this sample Screen.ActiveForm, but I have a cases when I know
jus a name of the form and I must pass TForm parameter to a procedure
by form's name!

I think that will help you to understand a problem! :D
The best practice is to keep a reference for all forms you create. If
you create a form without an instance variable or other reference you
can get a reference from the Screen.Forms array.
function FindForm(FormName: String): TForm;
var
I: Integer;
begin
for I := 0 to Screen.Forms.Count - 1 do
if Screen.Forms[I].Name = FormName then
begin
Result := Screen.Forms[I];
Break;
end;
end;
--
Bill Todd (TeamB)
 

Re:Call Form in runtime

Bill Todd wrote :
Quote
The best practice is to keep a reference for all forms you create. If
you create a form without an instance variable or other reference you
can get a reference from the Screen.Forms array.

function FindForm(FormName: String): TForm;
var
I: Integer;
begin
for I := 0 to Screen.Forms.Count - 1 do
if Screen.Forms[I].Name = FormName then
begin
Result := Screen.Forms[I];
Break;
end;
end;
That is it! Thaks again ... ;-)
--
regards,
sasa mihajlovic
XXXX@XXXXX.COM
www.msdinfo.com