Page 1 of 1

Switching between custom windows

PostPosted: Sun Mar 22, 2015 11:47 am
by ebear
Hello All,

I have a login system. The user can choose between User/Password, RFID and PIN login.
The three login windows are CustomWindows and each login windows has two buttons to change to another login type.
When switch three times beween the login types, it look that the CustomWindow isn't exlusive anymore and the script runs futher.
Below output from the debug screen with comments.

Does anyone know what is going wrong????

Best regards,

Eric

Code: Select all
Plug-In
+ GoSub "alStartup"

 Subroutines > alStartup
 + Call "Lunar\Wait.ebf" "ON"

  Function > Lunar\Wait.ebf
  + If "[OnOff]" "=" "ON"
  + CustomWindow "" "-1000" "-1000" "MASK" "NoBorder"
  + zmSetCustomWindowTransparent "MASK" "30"
  + zmSetCustomWindowPos "MASK" "0" "0" "[ScreenWidth]" "[ScreenHeight]" "ScreenPos" ""
  + CustomWindow "" "-1" "-1" "MASK" "NoBorder"
  + CustomWindow "" "-1" "-1" "WAIT" "NoBorder+NoCloseBtn"
  - Else
  - CloseCustomWindow "WAIT"
  - CloseCustomWindow "MASK"
  + EndIf
 + LoadVariables "[PubDir]ini\settings.ini"
 + If "[ShowErrors]" "=" "0"
 + ShowErrors "False"
 - Else
 - ShowErrors "True"
 + EndIf
 + If "[dbpShowErrors]" "=" "0"
 + dbpShowErrors "No"
 - Else
 - dbpShowErrors "Yes"
 + EndIf
 + SetVar "[AppID]" "Lunar.Login"

.>>>> Here I set the default logintype, this will later on be retrieved from the Windows register <<<<<

 + SetVar "[LoginType]" "PIN"
 + zmKBChangeLayout "[WinHandle]" "2"
 + GoSub "DBConnect"

  Subroutines > DBConnect
  + dbpOpenDatabase "LdB" "Provider=MSDASQL.1;Driver={MySQL ODBC 5.2 UNICODE Driver};Server=[MySQL-Server];Database=[MySQL-dB];User=[MySQL-User];Password=[MySQL-Pass];Option=3;charset=UTF8"
  + Return
 " .    Call "Lunar\Language.ebf"
 + Call "Lunar\Wait.ebf" "OFF"

  Function > Lunar\Wait.ebf
  + If "[OnOff]" "=" "ON"
  - CustomWindow "" "-1000" "-1000" "MASK" "NoBorder"
  - zmSetCustomWindowTransparent "MASK" "30"
  - zmSetCustomWindowPos "MASK" "0" "0" "[ScreenWidth]" "[ScreenHeight]" "ScreenPos" ""
  - CustomWindow "" "-1" "-1" "MASK" "NoBorder"
  - CustomWindow "" "-1" "-1" "WAIT" "NoBorder+NoCloseBtn"
  + Else
  + CloseCustomWindow "WAIT"
  + CloseCustomWindow "MASK"
  + EndIf
 + GoSub "Login"

.>>>>> First open the default logintype <<<<<
  Subroutines > Login
  + CloseCustomWindow "UP"
  + CloseCustomWindow "RFID"
  + CloseCustomWindow "PIN"
  + CloseCustomWindow "LF"
  + If "[LoginType]" "=" ""
  - CustomWindow "Login" "-1" "-1" "UP" "DialogBox+Exclusive+NoCloseBtn"
  + Else
  + SetVar "[User]" ""
  + SetVar "[Password]" ""
  + SetVar "[RFID]" ""
  + SetVar "[PIN]" ""
  + CustomWindow "Login" "-1" "-1" "[LoginType]" "DialogBox+Exclusive+NoCloseBtn"

.>>>> Now change from PIN to RFID <<<<<<

   PIN_RFID_Button > Left Click
   + SetVar "[LoginType]" "RFID"
   + GoSub "Login"

    Subroutines > Login
    + CloseCustomWindow "UP"
    + CloseCustomWindow "RFID"
    + CloseCustomWindow "PIN"
    + CloseCustomWindow "LF"
    + If "[LoginType]" "=" ""
    - CustomWindow "Login" "-1" "-1" "UP" "DialogBox+Exclusive+NoCloseBtn"
    + Else
    + SetVar "[User]" ""
    + SetVar "[Password]" ""
    + SetVar "[RFID]" ""
    + SetVar "[PIN]" ""
    + CustomWindow "Login" "-1" "-1" "[LoginType]" "DialogBox+Exclusive+NoCloseBtn"


.>>>>> Now change from RFID to User/Password UP <<<<<<

     RFID_Keyboard_Button > Left Click
     + SetVar "[LoginType]" "UP"
     + GoSub "Login"

      Subroutines > Login
      + CloseCustomWindow "UP"
      + CloseCustomWindow "RFID"
      + CloseCustomWindow "PIN"
      + CloseCustomWindow "LF"
      + If "[LoginType]" "=" ""
      - CustomWindow "Login" "-1" "-1" "UP" "DialogBox+Exclusive+NoCloseBtn"
      + Else
      + SetVar "[User]" ""
      + SetVar "[Password]" ""
      + SetVar "[RFID]" ""
      + SetVar "[PIN]" ""
      + CustomWindow "Login" "-1" "-1" "[LoginType]" "DialogBox+Exclusive+NoCloseBtn"

. >>>> Again change from UP to RFID <<<<<

       UP_RFID_Button > Left Click
       + SetVar "[LoginType]" "RFID"
       + GoSub "Login"

        Subroutines > Login
        + CloseCustomWindow "UP"
        + CloseCustomWindow "RFID"
        + CloseCustomWindow "PIN"
        + CloseCustomWindow "LF"
        + If "[LoginType]" "=" ""
        - CustomWindow "Login" "-1" "-1" "UP" "DialogBox+Exclusive+NoCloseBtn"
        + Else
        + SetVar "[User]" ""
        + SetVar "[Password]" ""
        + SetVar "[RFID]" ""
        + SetVar "[PIN]" ""
        + CustomWindow "Login" "-1" "-1" "[LoginType]" "DialogBox+Exclusive+NoCloseBtn"

. >>>> And now it goes wrong <<<<
        + EndIf
        + Return
      + EndIf
      + Return
    + EndIf
    + Return
  + EndIf
  + Return
 + Return

Re: Switching between custom windows

PostPosted: Mon Mar 23, 2015 10:50 am
by Neosoft Support
That's strange. Maybe a simpler solution would be to have a single custom window and place the different log-in components on separate containers. Then hide or show the appropriate containers as needed.

Re: Switching between custom windows

PostPosted: Mon Mar 23, 2015 12:34 pm
by ebear
Hello Dave,

I tried several ways, also what you propose. Mostly I run into problems one or the other.

But...

Now I change the whole way to archive the same, which also gives me some improvements:

Login system is a standalone application, the different ways to Login are each a on a separate page. Switching between these pages changes the login type.
After the user login is correct, the application runs the main application (these are renamed to eg. app.dll). The login app gives the user login as a parameter to the main app.
This gives me also the possibility to have one login system (reading the windows register) to start different applications eg the office application or the workfloor application.
Before the workstations can be used a setup is needed, which writes the default application to start in the register.

Sequence:

1. Start login application
2. Check if first setup is done
Yes... Goto 3
No... Run setup application
3. User login
4. Start application (as in Windows register)

The main applications cannot be started standalone, parameters are checked to start. (I did a rename from exe to dll to protect users to start????)
Maybe gives this approach other Neobookers also ideas for their projects.

If someone has a better idea, I'm open for discussion.

Best regards,

Eric

Re: Switching between custom windows

PostPosted: Mon Mar 23, 2015 1:49 pm
by Gaev
Eric:
Looks like you are trying to ... Open a CustomWindow (in exclusive mode) from within another CustomWindow (also in exclusive mode) ... and Close all other CustomWindows (whether opened or not) from within the opened CustomWindow ... and also trying to recursively call the Login Subroutine ... any number of unexpected behaviours can result from this approach.

Perhaps you might want to setup a (While) Loop that will close each CustomWindow before opening the next one e.g. ...
Code: Select all
SetVar "[NextAction]" ""
While "[NextAction]" "<>" "ExitLoop"
   If "[LoginType]" "=" ""
      CustomWindow "Login" "-1" "-1" "UP" "DialogBox+Exclusive+NoCloseBtn"
   Else
      SetVar "[User]" ""
      SetVar "[Password]" ""
      SetVar "[RFID]" ""
      SetVar "[PIN]" ""
      CustomWindow "Login" "-1" "-1" "[LoginType]" "DialogBox+Exclusive+NoCloseBtn"
   EndIf
EndWhile


... and change the code in the various Buttons to something like ...
Code: Select all
SetVar "[LoginType]" "whatever"
CloseCustomWindow "currently opened custom window"


... and when user has successfully completed one of the Logins, just ...
Code: Select all
SetVar "[NextAction]" "ExitLoop"
CloseCustomWindow "currently opened custom window"

Re: Switching between custom windows

PostPosted: Mon Mar 23, 2015 2:10 pm
by ebear
Hello Gaev,

Yes this is the way to do it you're right, my approach is wrong.
But I will stay at the way I described above, I think it is a little bit simpler.
Also even when I tried my CustomWindow approach, the login system was a separate application, it gives me more flexibility.

Gaev thanks a lot for your reaction.

Best regards,

Eric

Re: Switching between custom windows

PostPosted: Fri Mar 27, 2015 8:59 am
by stevec
I have a app that I built that uses several custom windows.

I just used the following

CloseCustomWindow "Group5"
CloseCustomWindow "Group6"
CustomWindow "Office 2003" "106" "195" "Group4" "FixedPos"