I want to create a Login/Password dialog which will prompt when someone click a specific button in my Delphi project. If the criteria entered are correct the user can proceed and open the form, the button opens. If not the button must not open the form. For example my MainForm starts with 2 buttons. Both Buttons, when clicked, open a different form. I want to implement the Login/Password function to one of these buttons. I use Delphi 2010.
-
4if I'm not mistaken, Delphi has a login template form... anyhu, file->new form->drop two edits, set password char to "*" for the password edit, drop two buttons, set modalresult = mrOK to the Login/OK button, set mrCancel to the Cancel button and implement the logicuser497849– user4978492012-02-28 12:26:31 +00:00Commented Feb 28, 2012 at 12:26
2 Answers
The operating system provides such services, namely CredUIPromptForCredentials for XP, and CredUIPromptForWindowsCredentials for Vista and up. The JEDI libraries expose this through the JwaWinCred.pas unit.
These don't look like being the easiest API functions to call, but they do have the obvious benefit of being system native and so should give a good look and feel.
Comments
You can make a login-function to which you also pass a TForm variable that has to be opened when login is correct. Or you can have the forms check if the user is logged in when they are opened.
There are many different approaches to this problem, you will have to decide for yourself which method is the best for your situation. Did you already try something that we can comment on?