Mega Code Archive

 
Categories / Delphi / Examples
 

Invoking the windows browse for folder dialog

Borland's SelectDirectory browser is quite ugly, here is how to invoke the Windows one instead. uses ShlObj, ShellAPI; ...... function BrowseForFolder(handle : HWND; strTitle : string; var strPath : string) : boolean; var info : TBROWSEINFO; path : array[0..MAX_PATH] of Char; items : PITEMIDLIST; begin Result:=false; path:=''; with info do begin hwndOwner:=handle; pidlRoot:=nil; pszDisplayName:=nil; lpszTitle:=PChar(strTitle); ulFlags:=BIF_RETURNONLYFSDIRS; lpfn:=nil; end; items:=SHBrowseForFolder(info); if assigned(items) then begin SHGetPathFromIDList(items,path); Result:=true; end; strPath:=Path; end;