| | |
trying to use one form to open another form
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 100
Reputation:
Solved Threads: 2
I have one form that is doing a security check. if the serial number or whatever is found, then a button will appear to open the actual program.
Welp, that isnt working out so well.
How do I have a Tbutton open another form and close the first form? This has been quite frustrating. I have tried everything I know. Under Options I have the first form under auto-create. The other form is under available forms. No matter what i try, I cant get the other form to show up and the first form to disappear.
Any help would be greatly appreciated.
Welp, that isnt working out so well.
How do I have a Tbutton open another form and close the first form? This has been quite frustrating. I have tried everything I know. Under Options I have the first form under auto-create. The other form is under available forms. No matter what i try, I cant get the other form to show up and the first form to disappear.
Any help would be greatly appreciated.
•
•
Join Date: Sep 2007
Posts: 69
Reputation:
Solved Threads: 7
•
•
•
•
I have one form that is doing a security check. if the serial number or whatever is found, then a button will appear to open the actual program.
Welp, that isnt working out so well.
How do I have a Tbutton open another form and close the first form? This has been quite frustrating. I have tried everything I know. Under Options I have the first form under auto-create. The other form is under available forms. No matter what i try, I cant get the other form to show up and the first form to disappear.
Any help would be greatly appreciated.
There are several ways of accomplishing what you have described. The technique I tested out is best understood by looking at the code in the attachment to the message and trying out the exe that is enclosed.
- As you almost certainly know, a Delphi application can be assigned a main form
- When the mainform is destroyed the application terminates.
- An interesting property is TApplication.ShowMainForm. By default this is true - you can set it to false as I have done. Look at the .DPR code using the Project Menu, Show Source menu item.
- Actually, this is not necessary - you can simply make the MainForm invisible by setting its Visible property to False.
- All Delphi objects have a virtual method called AfterConstruction that does nothing. However you can override it to do special processing. This is what I have done in TMaster.AfterConstruction. I call the RunApplication method in Opener.PAS.
- Here we open a small modal dialog and secure validation information as required. In your case this is a password. For the demo I simply ask for a number to be entered.
- The return result from RunApplication is tested in TMaster.AfterConstruction. If it is "wrong" we supply a suitable message. Otherwise we simply show the Application MainForm
- Note that I have in fact turned your problem on its head - you were trying to create the MainForm from your serial number validation form. I create the mainform anyway but just make it invisible. The validation form is created, used and destroyed in RunApplication.
Hope this helps. Like I said, there are umpteen other ways to do this.
![]() |
Similar Threads
- How to check if form is open (Visual Basic 4 / 5 / 6)
- Printing of a Form in VB.NET? (VB.NET)
- change which form to start with (Visual Basic 4 / 5 / 6)
- By Pressing F3 on MDI Form(Parent) How can a sub menu Form will open (Visual Basic 4 / 5 / 6)
- MDI Child Form Placement (C#)
- file open code in VB (Visual Basic 4 / 5 / 6)
- Blank Record & Open Form From Datagrid (C#)
- owner form display problem (VB.NET)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: write wav
- Next Thread: Procedure for deleting array content
Views: 7845 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi






