Consultor Eletrônico



Kbase 33037: How to programmatically select a directory
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Solution ID: P3037

GOAL:

How to programmatically select a directory

FACT(s) (Environment):

Windows

FIX:

The following sample code shows how to use Progress 4GL to invoke a Windows "browse for folder" window 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 SHGetPathFromIDList EXTERNAL "shell32.dll":
  DEFINE INPUT        PARAMETER mPoint AS LONG.
  DEFINE INPUT-OUTPUT PARAMETER cVar   AS CHARACTER.
 DEFINE RETURN       PARAMETER lRet   AS LONG.

END.

/* Call the procedures - in trigger code (.. ON CHOOSE OF btn-1): */

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).

MESSAGE cVar VIEW-AS ALERT-BOX.