Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating forms at runtime 1

Status
Not open for further replies.

rogerte

Programmer
Nov 9, 2001
164
GB
I have just changed to Delphi 7 from Delphi 4, and have run into a small problem. Won't accept code to create a form (derived from an existing form) at runtime.

One application (MDI style) use a form that is created at design time, it is in the Projects Uses declaration, but is not created at start up. When I need to use it I create in in a procedure as:
fNewForm := CustomerForm.create(Application);
fNewForm.show;

and in the form I have a release statement.
This is to allow the operator to have many customer (well limited to 4 actually by the program design) details on screen at the same time, and to work on each independently.

Only problem is - won't compile under Delphi 7 - doesn't like the create method.

Can't see how to do it in the help

Can anyone point me in the right direction - and does anyone know if this is cobvered in any of the books on Delphi 7?

Many thanks

Roger
 
What is the error message produced by the compiler? The actual message should give a clue to the problem.

Andrew

 
hi,

try this methode:

with TCustomerForm.Create(Application) do
try
Show;
finally
Free;
end;

I donn't know exactly all the differences but I think that the T in front of CustomerForm does the trick. In this case it a class.
so your function should read

fNewForm := TCustomerForm.create(Application);
fNewForm.show;


Steph [Bigglasses]

 
Svanhoost

I think you might be on the right track with this, because the error message has changed from "Create is not a method" to "Undeclared identifier".

I have "Used" the base form in the project dpr. SHould it be used in the shell form's forms declaration (ie the MDI main form, on which the fNewForm is displayed?
 
Svanhoost

You were absolutely correct in your reply - the other problem was caused by a spelling mistake that the compiler didn't pick up on!

Thanks a lot

Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top