How best to handle a login/password window?

Started by Dan English, July 04, 2011, 12:28:40 AM

Previous topic - Next topic

Dan English

I have created a login form that is set as the project's startup form.  This form contains code to check a password against a database.  If correct, this login form needs to be closed, and the program's main form loaded so that the user can go on his merry way. (Pretty much the procedure most secured apps use I would think.)

The problem I'm running into is -- I can't get both the program's main form opened, and the login form closed without the entire application unloading.

Can someone recommend a way to handle this?

Paul Squires

Paul Squires
PlanetSquires Software

Dan English

Very nice, thanks!  I searched the forums, but obviously missed this one.

I'll give it a try after my day job!

Rolf Brandt

Here is a minimal project for asking for a license key.

It simply writes the license key to an ini file. If the license key is there the program will start, if not it will open a dialog to enter a valid license key. Again if the license key is valid the program will save the key and start the program, if the license key is not valid the program will be terminated.

You would need to write your routines to check for the validity of a license key. Also where you want to store the license information, encryption, etc.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Dan English

Paul - thanks, we now have a working login screen.

Now here's a little twist...  using this method, the startup form is shown first, and then the login form as a modal.  Is there a way to hide the startup form until the login form is successful?

Sean Roe

This is how I did mine:

Function FRMMAIN_WM_CREATE ( _
                           hWndForm As Dword, _      ' handle of Form
                           ByVal UserData As Long _  ' optional user defined Long value
                           ) As Long
   'Show login dialog
   Local nReturn As Integer
   nReturn = Logon_Show(hWndForm, %True)
   
   If nReturn = %False Then
      FF_CloseForm hWndForm
   End If                   

End Function

Dan English

Thanks Sean -- give your code a go, and works great.

Sean Roe