I want something like openFileDialog but I want it to return a path that I can then use as a default location for future operations.
I found this:
https://learn.microsoft.com/en-us/windo ... eforfolder
which calls Shell32.dll but how do I do that, and is there an easier way?
Browse for Folder - How?
-
- Posts: 603
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Browse for Folder - How?
Use the WIndows API function SHBrowseForFolder
https://learn.microsoft.com/en-us/windo ... forfoldera
https://learn.microsoft.com/en-us/windo ... forfoldera
Re: Browse for Folder - How?
hello Macq
maybe this will be of help viewtopic.php?p=262364&hilit=open+dialog#p262364
maybe this will be of help viewtopic.php?p=262364&hilit=open+dialog#p262364
Re: Browse for Folder - How?
Simple browser to navigate to a folder.
Code: Select all
#include "windows.bi"
#include "win\shlobj.bi"
Function folderbrowser (Byref title As String = "Choose A Folder") As String
Dim bi As BROWSEINFO
Dim pidl As LPITEMIDLIST
Dim physpath As Zstring * MAX_PATH
Dim dispname As Zstring * MAX_PATH
bi.hwndOwner = HWND_DESKTOP
bi.pszDisplayName = @dispname
bi.lpszTitle = Strptr(title)
bi.ulFlags = 0
bi.lpfn = null
bi.lParam = 0
bi.iImage = 0
pidl = SHBrowseForFolder(@bi)
If pidl <> 0 Then
If SHGetPathFromIDList(pidl, physpath) = 0 Then
Function = ""
Else
Function = physpath
End If
CoTaskMemFree pidl
Else
Function = ""
End If
End Function
print folderbrowser
sleep
Re: Browse for Folder - How?
Thanks for all the help, and a special thanks to dodicat for that sweet little example. 

-
- Posts: 8631
- Joined: May 28, 2005 3:28
- Contact:
Re: Browse for Folder - How?
Code: Select all
#include "win\shlobj.bi"
function BrowseForFolder(byval pszTitle As const zstring ptr = @"Choose A Folder") As String
static as Zstring * MAX_PATH path
Dim As BROWSEINFO bi
bi.hwndOwner = HWND_DESKTOP
bi.lpszTitle = pszTitle
bi.ulFlags = BIF_USENEWUI
var pidl = SHBrowseForFolder(@bi)
If pidl = NULL then return ""
var bResult = SHGetPathFromIDList(pidl, path)
CoTaskMemFree(pidl)
return iif(bResult,path,"")
end function
print BrowseForFolder("what's up babe :-) resize, reorder or drag and drop !")
sleep