1. Computing & Technology

Discuss in my forum

in Advanced Delphi ::
If you need to implement some kind of authorization for your Delphi application you might want to display a login / password dialog *before* the main form is created and displayed to the user. In short, the idea would be to create, display, and destroy the "login" dialog before creating the main form.

Read the full article to learn how to Display a LogIn Dialog Before the Main Form of a Delphi Application is Created

Related:

Comments
February 21, 2007 at 11:17 am
(1) Durmus Celep says:

Hi,

I had been trying to solve this problem for a long time until giving up. I couldn’t deal with the fact that first created form become the main form of the application. Creating the password dialog without an owner is a great solution.

But I have a question. Can I create other modal forms in password dialog? Which owner(application or login dialog) should I use?

Anyway, thanks Zarko! Keep it coming.

Durmus
DC005001

February 21, 2007 at 11:38 am
(2) Durmus Celep says:

I forgot to ask:

Is there a way to hide application button from the taskbar until the main form is created without setting WS_EX_TOOLWINDOW for hidden application window?

February 21, 2007 at 2:09 pm
(3) Zarko Gajic says:

Durmus, yes you can create other form. Owner should be NIL, as in:
http://delphi.about.com/od/adptips2005/qt/nilselfapp.htm

February 28, 2007 at 12:42 am
(4) Ron Tuijnman says:

As an alternative I would suggest to use a tPageControl (align with client) with the pagetabs hidden. In your code just set the tabSheet with the log-in as active page. Now you can validate the user and switch to the other page(s) progammaticly or quit the application.
Very simple, as far as I know idiot proof and now you got the possibility to show a logo. And your application gets a ’standard look and feel’ in stead of form of different sizes.

February 28, 2007 at 12:47 pm
(5) sriram says:

HI,
I am getting 2 errors when i try to compile.
1. unit Graphics is not being found. I verified that this unit is available in $BDS\lib.
2. Error ‘ Unsatisfied forward or external declaration: TLoginForm.FormCreate”

how can i fix these?
i am using turboexplorer delphi, WIN2k

thanks

March 3, 2007 at 7:28 am
(6) Dave Cramp says:

Have tried this in an existing application. I never get as far as seeing the Passoword form. It falls over on “if TLogInForm.Execute Then …” with the message “Exception EAccess Violation…”

November 27, 2009 at 6:26 am
(7) Zarko Gajic says:

@sriram: I’ve fixed the code example. Form OnCreate is not used.

November 27, 2009 at 6:28 am
(8) Zarko Gajic says:

@Dave: I would need more info: on what line does this AV happen?

November 27, 2009 at 6:47 am
(9) Fajar says:

hi zarko,,
can i change the main Form at runtime? for example,,i have two forms,,MainForm(is mainform at design),and at runtime i want to change the main form to form2….
i try with method application.mainForm:=Form2; but an error ocured,,thnaks be4

December 2, 2009 at 4:11 am
(10) iwan cs says:

Hmm.. i have another method to show login dialog before main form, and i use it up until now, if you find a flaws with this method, please let me know.
So to show a login dialog before the main form showing, i use Application.ShowMainForm := False. So in the program unit, should look like this:
Application.ShowMainForm := False;
Application.CreateForm(TMainForm,TForm);
Application.CreateForm(TLoginForm,TForm);
Application.Run;

And on the login form, we will show the main form with MainForm.Show after a successful login.

Iwan CS

March 14, 2012 at 4:40 pm
(11) mark says:

Hi,
I have one question… How to do a loop with login dialog after wrong login?
Thank you.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2012 About.com. All rights reserved.

A part of The New York Times Company.