Reputation:
I have a delphi application where the main form is a login form - this contains various database and user objects necessary for the program. Once the user logs in, I hide this form and open another.
My issue is, how do I cause the application to minimize when the child form is minimized? I figured out how to restore the child when the main is restored using windows messages, but I can't figure out how to get the app to minimize so when they click on the taskbar they only have to click once - not once to minimize and then again to restore.
Any help is appreciated - I was trying to use the NCACTIVATE - but that causes endless loops in some cases with print dialogs and other windows...
Thanks, Christy
Upvotes: 0
Views: 1028
Reputation: 2846
i use TMinModal to minimize my app when a non-main form is minimized.
http://vvv.truls.org/pascal/Units.Delphi/UI/MinModal.pas
Upvotes: 0
Reputation: 15538
Why not make the main form the existing child form, put the database logic in a data module, and create and handle the login form manually? This is the pattern that I generally use:
Create a datamodule which will be auto-created FIRST in the list (before the main form). Tee datamodule in the OnCreate will initialize the database and display a login form which is NOT in the auto-create list, and is created and handled entirely in the datamodule. If I need a splash screen, then the datamodule also provides that functionality in the same manner.
The mainform OnCreate checks to insure that the user logged in successfully, if not then calls application.terminate;
Upvotes: 2
Reputation: 38703
The best way I have found is a slight change in architecture. You don't want your login form to be your application's main form. You can fix this two different ways, but since you are maintaining your database controls on your login form then I think this is the ideal way.
Ideally you should move all the database components into a DataModule so you can free your LoginForm once login is complete.
Upvotes: 3