Kbase P3037: How to programmatically select a directory?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  19/06/2008 |
|
Status: Verified
GOAL:
How to programmatically select a directory?
GOAL:
How to select a directory using Progress 4GL?
GOAL:
SYSTEM-DIALOG GET-FILE statement cannot select a directory.
FACT(s) (Environment):
Progress 9.x
Windows
FIX:
The following sample code shows how to use the Progress 4GL to invoke the Windows 'Browse for Folder' functionality so that you can select a directory:
PROCEDURE SHBrowseForFolder EXTERNAL "shell32.dll":
DEFINE INPUT PARAMETER mPoint AS MEMPTR.
DEFINE RETURN PARAMETER lRet AS LONG.
END PROCEDURE.
PROCEDURE SHGetPathFromIDList EXTERNAL "shell32.dll":
DEFINE INPUT PARAMETER mPoint AS LONG.
DEFINE INPUT-OUTPUT PARAMETER cVar AS CHARACTER.
DEFINE RETURN PARAMETER lRet AS LONG.
END PROCEDURE.
/* Call the procedures - in trigger code (.. ON CHOOSE OF SomeButton) */
DEFINE VARIABLE mPoint AS MEMPTR NO-UNDO.
DEFINE VARIABLE cVar AS CHARACTER NO-UNDO.
DEFINE VARIABLE iRet AS INTEGER NO-UNDO.
DEFINE VARIABLE iRet2 AS INTEGER NO-UNDO.
SET-SIZE(mPoint) = 1000.
ASSIGN cVar = FILL(" ",255).
RUN SHBrowseForFolder (mPoint, OUTPUT iRet).
RUN SHGetPathFromIDList (iRet, INPUT-OUTPUT cVar, OUTPUT iRet2).
SET-SIZE(mPoint) = 0.
MESSAGE "Selected Directory =" cVar VIEW-AS ALERT-BOX.