Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Login Dialog : Adding LoginDlg.cls to the project : Adding interface and login methods to LoginDlg.cls
 

Adding interface and login methods to LoginDlg.cls

To complete the login dialog you must add code for the interface methods for the form. When you created LoginDlg.cls, you specified that the form would implement the IStyling, IUser, and IHelpCallback interfaces. Templates for the interface methods were automatically added to LoginDlg.cls. Now you must complete the templates for those methods.
In addition, you must add some methods (ValidateLoging and LookupLogin) to complete the "plumbing" that handles logins.
To add interface and login methods to LoginDlg.cls:
1. If LoginDlg.cls is open in Visual Designer, press F9 to view source.
You can also right click on the file name in the Project Explorer view and select Open With > OpenEdge ABL Editor.
2. Find and select the interface method templates in the file:
METHOD PUBLIC VOID SetStyle( INPUT styleFile AS System.IO.FileInfo ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.

METHOD PUBLIC VOID SetUser( INPUT name AS CHARACTER, INPUT password AS CHARACTER ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext( OUTPUT pcHelpFilename AS CHARACTER ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext( OUTPUT pcHelpFilename AS CHARACTER, OUTPUT pcHelpKeyword AS CHARACTER ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext( OUTPUT pcHelpFilename AS CHARACTER, OUTPUT poHelpNavigator AS System.Windows.Forms.HelpNavigator ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext( OUTPUT pcHelpFilename AS CHARACTER, OUTPUT poHelpNavigator AS System.Windows.Forms.HelpNavigator,
OUTPUT pcTopicIdentifier AS CHARACTER ):
     UNDO, THROW NEW Progress.Lang.AppError("METHOD NOT IMPLEMENTED").
END METHOD.
3. Replace the interface templates with the following code:
METHOD PUBLIC VOID SetStyle( INPUT styleFile AS System.IO.FileInfo ):
    Infragistics.Win.AppStyling.StyleManager:Load( styleFile:FullName ).
    appStylistRuntime1:LoadFromStyleManager().
END METHOD.

METHOD PUBLIC VOID SetUser( INPUT name AS CHARACTER, INPUT pwd AS CHARACTER ):
    loginBlock1:loginName:Text = name.
    loginBlock1:loginPwd:Text = pwd.
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext (OUTPUT pcHelpFilename AS CHARACTER):
    RETURN FALSE.
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext (OUTPUT pcHelpFilename AS CHARACTER,
OUTPUT pcHelpKeyword AS CHARACTER):
    RETURN FALSE.
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext (OUTPUT pcHelpFilename AS CHARACTER,
OUTPUT poHelpNavigator AS HelpNavigator):
    RETURN FALSE.
END METHOD.

METHOD PUBLIC LOGICAL GetHelpContext (OUTPUT pcHelpFilename AS CHARACTER,
OUTPUT poHelpNavigator AS HelpNavigator,
OUTPUT pcTopicIdentifier AS CHARACTER):
    /* Example */
    pcHelpFilename = search('prohelp/masteng.chm').
    poHelpNavigator = HelpNavigator:Index.
    pcTopicIdentifier = ''.
    RETURN TRUE.
END METHOD.
4. Before the END CLASS statement, add the following code that verifies logins:
METHOD PRIVATE LOGICAL ValidateLogin( ):
    IF THIS-OBJECT:loginBlock1:loginName:Text = "" THEN DO:
      MESSAGE "Please enter a login name" VIEW-AS ALERT-BOX.
      THIS-OBJECT:loginBlock1:loginName:Focus().
      RETURN FALSE.
    END.
    IF LookupLogin(THIS-OBJECT:loginBlock1:loginName:Text,
    THIS-OBJECT:loginBlock1:loginPwd:Text) = FALSE THEN DO:
      MESSAGE "Invalid login name and password combination" VIEW-AS ALERT-BOX.
      THIS-OBJECT:loginBlock1:loginPwd:Focus().
      RETURN FALSE.
    END.
    RETURN TRUE.
END METHOD.

METHOD PRIVATE LOGICAL LookupLogin( name AS CHAR, pwd AS CHAR):
    IF name = pwd THEN RETURN TRUE.
    ELSE RETURN FALSE.
END METHOD.
5. To ensure that class and interface references are valid, add the following to the USING statements section near the top of the file:
USING Progress.Windows.*.
USING Progress.Lang.*.
USING openedge.tutorial.ui.*.
USING System.Windows.Forms.*.
6. Save and close LoginDlg.cls.