
Code: Alles auswählen
; PathRequesterEx
; Windows Only
; PB 4.40 and above
; Author: Thomas <ts-soft> Schulz
; CoAuthor: Stephen <srod> Rodriguez
; Version 1.1, 24.04.2010
;
; The first and second parameter the same as in PB
;
; you can use a CSIDL-Constant (optional), InitialPath will be ignored!
; CSIDL-Constants see: http://msdn.microsoft.com/de-de/library/bb979138.aspx
;
; for Flags see http://msdn.microsoft.com/en-us/library/bb773205%28VS.85%29.aspx
;
; No directory can be chosen above the initial directory!
EnableExplicit
Procedure.s PathRequesterEx(Title.s, InitialPath.s = "", CSIDL = #PB_Default, Flags = 0)
Protected.ITEMIDLIST *ppidl
Protected.BROWSEINFO Dir
Protected result
Protected.s folder = Space(#MAX_PATH)
Protected *Path, t1$
CoInitialize_(#Null)
If CSIDL = #PB_Default
*Path = AllocateMemory(StringByteLength(InitialPath, #PB_Unicode) + 2)
PokeS(*Path, InitialPath, -1, #PB_Unicode)
*ppidl = ILCreateFromPath_(*Path)
FreeMemory(*Path)
Else
SHGetSpecialFolderLocation_(GetActiveWindow_(), CSIDL, @*ppidl)
EndIf
With Dir
\hwndOwner = GetActiveWindow_()
\pidlRoot = *ppidl
\pszDisplayName = @folder
\lpszTitle = @Title
\ulFlags = Flags
EndWith
result = SHBrowseForFolder_(@dir)
If result And Dir\pszDisplayName
t1$ = Folder
SHGetPathFromIDList_(result, @Folder)
If Folder = ""
Folder = t1$
EndIf
CoTaskMemFree_(result)
EndIf
CoTaskMemFree_(*ppidl)
CoUninitialize_()
If Folder
If FileSize(Folder) = -2
If Right(Folder, 1) <> "\" : Folder + "\" : EndIf
EndIf
EndIf
ProcedureReturn Folder
EndProcedure
; Example:
Debug PathRequesterEx("Select savedir:", "", #CSIDL_PERSONAL)
Debug PathRequesterEx("Select PureBasic Source:", #PB_Compiler_Home + "Examples\Sources\", #PB_Default, #BIF_BROWSEINCLUDEFILES)
Debug PathRequesterEx("Select Printer:", "", #CSIDL_PRINTERS, #BIF_BROWSEFORPRINTER | #BIF_NEWDIALOGSTYLE | #BIF_NONEWFOLDERBUTTON)
Hab mit ASCII, Unicode, x86 und x64 getestet.
Gruß
Thomas