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.

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.

Squidd

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.

  1. As you almost certainly know, a Delphi application can be assigned a main form
  2. When the mainform is destroyed the application terminates.
  3. 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.
  4. Actually, this is not necessary - you can simply make the MainForm invisible by setting its Visible property to False.
  5. 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.
  6. 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.
  7. 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
  8. 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.

Thanks for your help ExplainThat... It was very well written out. I got it worked out without doing all the stuff you did.

Your way certainly works, however. :)

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.