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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using 1 pas file to control multiple forms

Status
Not open for further replies.

xepra

Programmer
Mar 31, 2001
5
AU
Is it possible to control multiple forms with one pas file? i'm using delphi 4, and any help would be greatly appreciated.
P.S please use detailed descriptions, cuase i'm a bit of a newbie
thanks
 
xepra,

Yes.

What are you trying to accomplish? It's tough to be detailed when shooting in the dark. Are you dealing with a specific error? What's the problem, what have you tried, what's not working for you?

-- Lance
 
Remember xepra, every form in delphi has his own unit. At least the visual forms.

If you have data, procedures etc which has to be available in different forms you have to declare it in a separate unit.

Example: You have an input form for two variables, and a result form where you do some processing with these variables.

To make the variables available for both forms you have to put them in a non visible (normal) unit:

New --> Unit

Below interface type the data types, variables and procedures which must be available for other forms or units

Below implementation define your procedures and functions



ex:


unit BasicData;

interface
Type
DataRecord = Record
Level : byte;
FileName : string[80];
HelpString : string[20];
end;

Var
Searcher, Actualrecord : DataRecord;
DataFile : File of DataRecord;

FileDir : string;

Procedure OpenIndexList_ForUpdate;
Procedure AtFirstRecord;
Procedure AtLastRecord;
Procedure AtNextRecord;
Procedure AtPreviousRecord;
Procedure AppendRecord(x : DataRecord);
Procedure Updaterecord(x : dataRecord);

Implementation
uses SysUtils;

Procedure OpenIndexList_ForUpdate;

begin
FileDir :='';
AssignFile (Datafile, FileDir + 'List.dta');
{$I-}
Reset(Datafile);
{$I+}
if IOresult <> 0 then Rewrite(DataFile);
end;
etc....
end.


In above example If defined my global data and procedures, and I make them available for other units with the command:
File ---> Use Unit


Hope this is what you are looking for S. van Els
SAvanEls@cq-link.sr
 
If I understand correctly, you are trying to create two forms, but save them in the same unit. This, unfortunately, is not doable to my current knowledge. I might be wrong, but the chances are slim. Because each form in Delphi automatically stores itsself and it's state to the DFM file, you cannot simply create another form in the DFM file if Delphi does not anticipate it. I have personally tried this, but to no avail.

Johan van den Berg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top