Date: 02-16-2022
Return to Index
created by gbSnippets
'PowerBASIC has a built-in DDT command to access the Windows folder browser
'Primary Code:
'Syntax: DISPLAY BROWSE [hParent], [xpos], [ypos], title$, start$, flags TO folder$
Display Browse hDlg, 100, 100, title$, start$, flags& To folder$
'Flag Options:
%BIF_BROWSEINCLUDEFILES 'The dialog box will display both files and folders.
%BIF_BROWSEINCLUDEURLS 'Display URL's (must set %BIF_USENEWUI and %BIF_BROWSEINCLUDEFILES).
%BIF_DONTGOBELOWDOMAIN 'Exclude network folders in treeview.
%BIF_EDITBOX 'Display edit control For user to enter information.
%BIF_NEWDIALOGSTYLE 'Advanced interface (larger, resizable, drag-and-drop, reordering, shortcut menus, new folders, delete, and other shortcut Menu commands.
%BIF_NONEWFOLDERBUTTON 'Exclude "New Folder" button.
%BIF_NOTRANSLATETARGETS 'Allow opening a shortcut (not the target file).
%BIF_RETURNFSANCESTORS 'File system ancestors only (OK button Is grayed on other types).
%BIF_RETURNONLYFSDIRS 'File system directories only (OK button Is grayed on other types).
%BIF_SHAREABLE 'Display remote, shareable resources (must set %BIF_NEWDIALOGSTYLE).
%BIF_UAHINT 'With %BIF_NEWDIALOGSTYLE, adds usage hint in lieu of edit box.
%BIF_USENEWUI 'Include edit box with advanced user interface.
%BIF_VALIDATE 'Require a valid result or CANCEL.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
Global hDlg As DWord
Function PBMain() As Long
Local title$, start$, flags&, folder$
title$ = "Select Folder" 'if "" then "Open" is used
start$ = Exe.path$
flags& = %BIF_ReturnOnlyFSDirs Or %BIF_DontGoBelowDomain Or %BIF_NoNewFolderButton
Display Browse hDlg, 100, 100, title$, start$, flags& To folder$
'folder$ is set to "" if Cancel/Escape is pressed
If Len(folder$) Then
MsgBox folder$
Else
MsgBox "No folder selected!" 'ESC or Cancel
End If
End Function
'gbs_00115
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm