Share your advanced PureBasic knowledge/code with the community.
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Fri Apr 23, 2010 7:24 pm
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
Last edited by
ts-soft on Sat Apr 24, 2010 12:46 pm, edited 1 time in total.
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Sat Apr 24, 2010 11:17 am
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.
I may look like a mule, but I'm not a complete ass.
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Sat Apr 24, 2010 11:27 am
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.
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Sat Apr 24, 2010 11:50 am
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?
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Sat Apr 24, 2010 12:29 pm
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.
Last edited by
srod on Sat Apr 24, 2010 12:48 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Sat Apr 24, 2010 12:46 pm
thanks again.
Code in first post updated!
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Sat Apr 24, 2010 12:49 pm
Could be useful this. Thanks.
I may look like a mule, but I'm not a complete ass.
SharkyEXE
User
Posts: 35 Joined: Sat Feb 26, 2022 6:33 pm
Post
by SharkyEXE » Sun Feb 27, 2022 9:15 am
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)