BBC BASIC for Windows
General >> General Board >> Selecting a file name from Browse
http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1262883154

Selecting a file name from Browse
Post by Danny72 on Jan 7th, 2010, 3:52pm

Hello

I would like to know if there is a way for the user to select a file from browsing folders, and for the filename and path to be stored in a string (perhaps if that is suitable). Many thanks.
Danny

I found the Browse folder code at http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#opensave



dim bi{hOwner%, pidlRoot%, pszDisplayName%, \
\ lpszTitle%, ulFlags%, lpfn%, lParam%, iImage%}
dim folder{t&(260)}
titlez$ = title$+chr$0
bi.hOwner% = @hwnd%
bi.pszDisplayName% = folder{}
bi.lpszTitle% = !^titlez$

sys "SHBrowseForFolder", bi{} to pidl%
if pidl% sys "SHGetPathFromIDList", pidl%, folder{}
folder$ = $$folder{}
sys "SHGetMalloc", ^malloc%
sys !(!malloc%+20), malloc%, pidl% : rem. IMalloc::Free

Re: Selecting a file name from Browse
Post by admin on Jan 7th, 2010, 4:13pm

Quote:
I would like to know if there is a way for the user to select a file from browsing folders

Browsing for folders (using SHBrowseForFolder) is, as the name suggests, only for selecting a folder (directory). If you want to select a file (or group of files) then use GetOpenFileName (or GetSaveFileName), which are documented in the same place:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#opensave

Richard.