Posts: 1,769
Threads: 410
Joined: Feb 2003
is there a way to be able to "backup" and choose other drives with this while still being able to start in a specific directory?
str s
if(BrowseForFolder(s "c:\qm")) out s
Keyword search
browse file directory
Posts: 11,869
Threads: 138
Joined: Dec 2002
Function BrowseForFolder2 (or replace BrowseForFolder):
;/
function# str&s [$initdir] [flags] [$text] ;;flags: 1 include files, 2 include non-file objects (Control Panel, etc), 4 new style
;Displays "Browse For Folder" dialog and stores full path of selected folder into s.
;Returns 1 on OK; 0 on Cancel.
;EXAMPLE
;str s
;if(BrowseForFolder(s "$windows$")) out s
;flags may also include one or more of the following commented values, lshifted by 8 bits. For example, to browse for computer, use 2|(0x1000<<8). For more info, search for SHBrowseForFolder in the MSDN Library.
def BIF_RETURNONLYFSDIRS 0x0001
;def BIF_DONTGOBELOWDOMAIN 0x0002
;def BIF_STATUSTEXT 0x0004
;def BIF_RETURNFSANCESTORS 0x0008
def BIF_EDITBOX 0x0010
;def BIF_VALIDATE 0x0020
def BIF_NEWDIALOGSTYLE 0x0040
def BIF_USENEWUI (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)
;def BIF_BROWSEINCLUDEURLS 0x0080
;def BIF_UAHINT 0x0100
;def BIF_NONEWFOLDERBUTTON 0x0200
;def BIF_NOTRANSLATETARGETS 0x0400
;def BIF_BROWSEFORCOMPUTER 0x1000
;def BIF_BROWSEFORPRINTER 0x2000
def BIF_BROWSEINCLUDEFILES 0x4000
;def BIF_SHAREABLE 0x8000
BROWSEINFO b
b.hwndOwner=win()
if(flags&1) b.ulFlags|BIF_BROWSEINCLUDEFILES
if(flags&2=0) b.ulFlags|BIF_RETURNONLYFSDIRS
if(flags&4) b.ulFlags|BIF_USENEWUI
b.ulFlags|flags>>8
b.lpszTitle=text
if(len(initdir))
,if(flags&4) b.lpfn=&BFF_Proc; b.lParam=initdir
,else b.pidlRoot=PidlFromStr(initdir)
ITEMIDLIST* pidl=SHBrowseForFolder(&b)
if(pidl) PidlToStr(pidl &s flags&2=0); CoTaskMemFree pidl; else s.all
if(b.pidlRoot) CoTaskMemFree b.pidlRoot
ret s.len
Function BFF_Proc:
function# hwnd uMsg lParam $lpData
def BFFM_INITIALIZED 1
def BFFM_SETEXPANDED WM_USER+106
sel uMsg
,case BFFM_INITIALIZED
,SendMessage hwnd BFFM_SETEXPANDED 1 _s.unicode(lpData)
Without flag 4, shows only initdir. With flag 4, shows all and expands/selects initdir.
Posts: 1,769
Threads: 410
Joined: Feb 2003