Kbase 18823: How to use ActiveX automation to invoke the Windows 'Browse for Folder' window so that the user can
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Verified
GOAL:
How to use ActiveX automation to invoke the Windows 'Browse for Folder' window so that the user can select a folder (directory).
GOAL:
How to use 'Browse for Folder' to select a folder
FACT(s) (Environment):
Windows ME
Windows 2000
FIX:
The code refers to the CURRENT-WINDOW handle. Alternatively use another window handle.
DEFINE VARIABLE oServer AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE oFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE oParent AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE cFolder AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
CREATE 'Shell.Application' oServer.
oFolder = oServer:BrowseForFolder(CURRENT-WINDOW:HWND,'Select Folder',0).
IF VALID-HANDLE(oFolder) = True THEN
DO:
ASSIGN cFolder = oFolder:Title
oParent = oFolder:ParentFolder
iCount = 0.
REPEAT:
IF iCount >= oParent:Items:Count THEN
DO:
MESSAGE 'No Folder Selected' VIEW-AS ALERT-BOX.
LEAVE.
END.
ELSE
IF oParent:Items:Item(iCount):Name = cFolder THEN
DO:
MESSAGE 'Selected Folder ='
oParent:Items:Item(iCount):Path
VIEW-AS ALERT-BOX.
LEAVE.
END.
ASSIGN iCount = iCount + 1.
END.
END.
ELSE
MESSAGE 'No Folder Selected' VIEW-AS ALERT-BOX.
RELEASE OBJECT oParent NO-ERROR.
RELEASE OBJECT oFolder NO-ERROR.
RELEASE OBJECT oServer NO-ERROR.