Re: disable Forms default login

From: <RTProffitt_at_beckman.com>
Date: Thu, 24 Jun 1999 17:14:29 GMT
Message-ID: <7ktp19$bkg$1_at_nnrp1.deja.com>


Yes deleona,
I have built a custom logon screen, in Forms 5 for Win/NT Here are some tips and tricks.

  1. I initialize some global variables:
default_value('C392310','global.DefaultUser');
default_value('BOEING' ,'global.DefaultPass');
default_value('_at_OATT'  ,'global.AtInstance');
default_value('x','global.CurrentUser');       -- temporary variables
for use by
default_value('x','global.CurrentPass');       -- On-Logon trigger,
LogonUser Module
default_value('x','global.CurrentAtInstance'); -- and LogonDefaultUser Proc

I actually did this in a procedure, InitGlobals, that I kept in a library
attached to all modules.

2. I build a module to be the custom logon box, which will be called by main module.

The Logon and Cancel buttons have triggers. a) Cancel calls a procedure LogonDefaultUser

    (In our case, there was always a default Read-Only user,     In your case, you might want something different)

b) Logon does the following.

  • various edit checks and error messages
    • you have not entered your password, etc.
  • Always logs out, then sets globals based on user input. logout; :global.CurUserID := null; :global.CurrentUser := :edtUserID; :global.CurrentPass := :edtPassword; :global.CurrentAtInstance := :global.AtInstance; (this one you may wish to hardcode if you want)
  • Key function: calls LOGON function. LOGON(name_in('global.CurrentUser'), name_in('global.CurrentPass') || name_in('global.CurrentAtInstance'), FALSE);

      Keyword FALSE is important.

  • Test for success and cleanup If FORM_FAILURE
    • warn user, and LogonDefaultUser call.
  • on success, Exit_Form(no_validate) Also have another global, useful for other modules 3. The Central Key point for success... ON-LOGON trigger.
    1. In the main Form, an ON-LOGON trigger is created. It has interesting properties. It intercepts all attempts to LOGON and executes the code in the trigger in its place....EXCEPT... a LOGON command which is executed from WITHIN the trigger is allowed to pass to be executed.... This is the key.
    2. When the main module first boots, we wish to trap the logon and continue on to Pre-Form trigger, where we can control the logon. (In my case, to logon to a default user and wait for User to press a Logon button...nevermind the reasons why, just accept that we wanted to control the logon in this way).
    3. Therefore: here is the code from the ON-LOGON trigger.

/* On-Logon trigger, trap first time boot up, otherwise perform logon for user. */

  • Check variable if exists, otherwise make one and set null. DEFAULT_VALUE(null, 'global.CurrentUser');

IF :global.CurrentUser is null THEN

  • global does not exist, therefore first time is true
  • just quit.
  • defer logon until PRE-FORM trigger. Erase('Global.CurrentUser'); NULL; ELSE
  • all other normal times.
  • ON LOGON gets called for every LOGON call
  • perform the LOGON for the user.
  • 12/07/98, rtp, add False, don't put default screen on failure.
  • just Fail the Form. LOGON(:global.CurrentUser, :global.CurrentPass || :global.CurrentAtInstance, FALSE); END IF; d) The Pre-Form trigger is very simple, in my case.
    • initialize various things....
    • call LogonDefaultUser procedure from my library. e) Remember that you may need more than one ON-LOGON trigger: for every module where you wish to intercept Logon. (In my case, it was only needed to intercept default logon, and only required in the one main module). 4. The LogonDefaulUser procedure. This is a simple procedure, centralized in a library so it is easily accessed by more than one module.
      1. Here is the full code:

PROCEDURE LogonDefaultUser IS
/* 11/18/98, set globals then call logon,which may

   invoke ON-LOGON trigger which will use the globals. */
BEGIN
  LOGOUT;

  • library procs cannot use colon-notation, use COPY instead
  • use Indirect (name_in), copy what's in default user into current user. COPY(NAME_IN('global.DefaultUser'),'global.CurrentUser'); COPY(NAME_IN('global.DefaultPass'),'global.CurrentPass'); COPY(NAME_IN('global.AtInstance'),'global.CurrentAtInstance'); LOGON(name_in('global.CurrentUser'), name_in('global.CurrentPass') || name_in('global.CurrentAtInstance'));

  /* If there is no ON-LOGON trigger, then this statement will

     execute as is.  When there is an ON-LOGON trigger the
     LOGON statement is intercepted by ON-LOGON and these
     parameters are never executed.  Instead, the LOGON inside
     of ON-LOGON is executed, which uses these same global
     variables to be successful.  */

END; b) Key point is that it performs LOGON call, which may or

    may not be executed, depending on any ON-LOGON trigger.     If this is a module with no trigger, then the LOGON is     executed as written. If there is a trigger, then LOGON     triggers the trigger, and the above trigger code performs     its own LOGON instead (just so happens that they are the     very same LOGON command, by design).

5) The User Button.

    One of my modules in the app contains the button I mentioned     before, to allow the user to ask to be logged on. It contains     a WHEN-BUTTON-PRESSED trigger which performs the following:

Call_Form('LBDLogonUser',no_hide);
if :global.LogonSuccess = 'C' then

  • Canceled RETURN; elsif :global.LogonSuccess = 'Y' then ... etc. do other stuff ...
    1. This button is what controls the calling of the custom form.

Good Luck
If anyone wishes more detail or discussion, you may contact me.

Robert Proffitt
Beckman Coulter
Brea, California, USA
RTProffitt_at_Beckman.com
714-993-8426

In article <7ktdp2$6kq$1_at_nnrp1.deja.com>,   deleona_at_my-deja.com wrote:

> I am new to Forms and trying to figure out how to disable the default
> Forms login window when running an .fmx.  I want to use my own custom
> login screen.  Any ideas?  Thanks in advance!
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Thu Jun 24 1999 - 19:14:29 CEST

Original text of this message