Page 1 of 1
PathRequesterEx (windows only)
Posted: Fri Apr 23, 2010 7:24 pm
by ts-soft
Code: Select all
; 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)
greetings
Thomas
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 11:17 am
by srod
Very interesting Thomas - thanks.
When I use :
Code: Select all
PathRequesterEx("my next title", "C:\", #CSIDL_PRINTERS, #BIF_BROWSEFORPRINTER)
then my printers get displayed, but the OK button is grayed out! Any idea how to enable the OK button?
Thanks again.
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 11:27 am
by ts-soft
srod wrote:When I use :
Code: Select all
PathRequesterEx("my next title", "C:\", #CSIDL_PRINTERS, #BIF_BROWSEFORPRINTER)
then my printers get displayed, but the OK button is grayed out! Any idea how to enable the OK button?
Thanks again.
you're welcome
in the moment, no idea of printers button.
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 11:50 am
by ts-soft
Code: Select all
Debug PathRequesterEx("my next title", "C:\", #CSIDL_PRINTERS, #BIF_BROWSEFORPRINTER | #BIF_NEWDIALOGSTYLE | #BIF_NONEWFOLDERBUTTON)
But no result
// edit
SHGetPathFromIDListEx API with #GPFIDL_UNCPRINTER should help?
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 12:29 pm
by srod
Two problems; one enabling the OK button and two, retrieving the printer name etc. The first one seems to require the #BIF_NEWDIALOGSTYLE style. The second problem needed some modification to your main routine.
REMOVED.
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 12:46 pm
by ts-soft
thanks again.
Code in first post updated!
Re: PathRequesterEx (windows only)
Posted: Sat Apr 24, 2010 12:49 pm
by srod
Could be useful this. Thanks.
Re: PathRequesterEx (windows only)
Posted: Sun Feb 27, 2022 9:15 am
by SharkyEXE
ts-soft
Hello
Please, write me, how change size window in your script
https://www.purebasic.fr/english/viewtopic.php?p=322480
Code: Select all
; 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)