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

Linking forms

Status
Not open for further replies.

DJDemonian

Technical User
Nov 6, 2013
4
Hi, I'm a Delphi Newbie still at young age. I want to know how to link two or more Forms in one Unit. I have searched and asked everywhere but don't seem to find any helpfull answers. HELP ME PLEASE [bomb]
 
Can you explain what you mean by Link two or more forms in one unit? If you want to access resources (variables/methods) of one form, from another form, then add the other form to the uses clause. If you want to define more than one form in one unit, not sure you can do that, and even if you can, I certainly wouldn't recommend it.
 
I want to use more than one form in a program. I know it's a rookie question but I just started using Delphi a while ago. ex : The first form is the start menu, then when clicked on a button, the form hides and the second form appears.
 
It's pretty straight forward. Create both of your forms in the designer, and then when you want to show the second form from your main form, you put that option in there. The compiler will put up a message saying something like "form1 references form2 which is in unit2, do you wish to add it?" and it'll go ahead and add it and compile.

As for actually handling the chore, all is required is to reference Form2.Show or Form2.ShowModal (if you want the form to stay until dismissed). If you want to hide the main form, it's Form1.Hide. Close the second form, it's Form2.Close or Form2.CloseModal. If you want to close the second form and reshow the main form (after calling hide), it's the same process, but you might have to call Form1.SetFocus for the form to show up again front-and-center.

Hope that helps.


It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top