$INCLUDE "rapidq.inc"
$DEFINE MAX_PATH 260
Private TYPE BrowseInfo
hWndOwner AS LONG
pIDLRoot AS LONG
pszDisplayName AS LONG
lpszTitle AS LONG
ulFlags AS LONG
lpfnCallback AS LONG
lParam AS LONG
iImage AS LONG
END TYPE
CONST BIF_USENEWUI = &H40
Private DECLARE FUNCTION lstrcat LIB "kernel32" ALIAS "lstrcatA" (BYVAL lpString1 AS STRING, BYVAL lpString2 AS STRING) AS LONG
Private DECLARE FUNCTION SHBrowseForFolder LIB "shell32" ALIAS "SHBrowseForFolderA"(lpbi AS BrowseInfo) AS LONG
Private DECLARE FUNCTION SHGetPathFromIDList LIB "shell32" ALIAS "SHGetPathFromIDListA"(BYVAL pidList AS LONG, BYVAL lpBuffer AS STRING) AS LONG
Private DECLARE SUB CoTaskMemFree LIB "ole32.dll" "AliasCoTaskMemFree"(BYVAL hMem AS LONG)
DECLARE SUB pShowFoldDlg(Sender AS QBUTTON)
Private FUNCTION ShowDLGFolder() AS STRING
DIM iNull AS INTEGER
DIM lpIDList AS LONG
DIM lResult AS LONG
DIM sPath AS STRING
DIM udtBI AS BrowseInfo
udtBI.hWndOwner = Form.Handle
udtBI.lpszTitle = lstrcat("C:\", "")
udtBI.ulFlags = BIF_USENEWUI
lpIDList = SHBrowseForFolder(udtBI)
IF lpIDList THEN
sPath = STRING$(MAX_PATH, 0)
SHGetPathFromIDList lpIDList, sPath
CoTaskMemFree lpIDList
iNull = INSTR(sPath, "")
IF iNull THEN
sPath = LEFT$(sPath, iNull - 1)
END IF
END IF
ShowDLGFolder = sPath
END SUB
CREATE Form AS QFORM
CAPTION = "Test browse for folder"
CREATE btnFolder AS QBUTTON
CAPTION = "Show"
OnClick = pShowFoldDlg
END CREATE
SHOWMODAL
END CREATE
SUB pShowFoldDlg
MESSAGEBOX(ShowDlgFolder,"",0)
END SUB
|