Login

.


Asterisks in password

The Progress fill-in widget has a :blank attribute that you can use when creating a password field. But most Windows applications use asterisks instead of blanks.
It's fairly simple to have asterisks (or any other password-character) in Progress too:

  {windows.i}
  DEFINE VARIABLE ReturnValue AS INTEGER NO-UNDO.
  RUN SendMessage{&A} IN hpApi (fill-in_password:HWND, 
                                {&EM_SETPASSWORDCHAR}, 
                                ASC("*"),
                                0,
                                OUTPUT ReturnValue).

Explanation

The third parameter is the new passwordchar. When 0, you disable the password feature.

Notes

You may have trouble reading fill-in_password:screen-value so instead you have to ASSIGN the fill-in and test the associated field or variable.
There is a small security risc: if you use debugtools like Spy++ you will see the contents of the fill-in in readable format, e.g. with no asterisks. This means it is fairly simple for a hacker to create a program that logs your passwords. This is not only true for this particular fill-in, but for every password field in MS-Windows. The normal :BLANK attribute however can not be spied: it only shows blanks.


GetUserName

The 'name' field (in a login dialog) can be initialized with the name by which the user is known in Windows.
You can try to find this name in the registry but you better let Windows do it for you, using the GetUserName function.

{windows.i}
 
   DEFINE VARIABLE NAME AS CHARACTER NO-UNDO.
   RUN WinUserName(OUTPUT NAME).
   fill-in_name:SCREEN-VALUE = NAME.
 
PROCEDURE WinUserName :
   DEFINE OUTPUT PARAMETER NAME AS CHARACTER.
 
   DEFINE VARIABLE nr AS INTEGER NO-UNDO INITIAL 100.
   DEFINE VARIABLE ReturnValue AS INTEGER NO-UNDO.
   NAME = FILL(" ", nr).
   RUN GetUserName{&A} IN hpApi (INPUT-OUTPUT NAME,
                                 INPUT-OUTPUT nr,
                                 OUTPUT ReturnValue).
END PROCEDURE.

notes

The 'fill' statement is important because it allocates memory. Windows hardly ever allocates memory for you.
There is one important drawback: the function GetUserName does not exist in 16-bit windows. If you are using a Progress version prior to 8.2 on Windows 95 you can still use this function but you will have to thunk it.