Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Delphi - Use the new Windows directory or folder selector in Delphi

2 Posts
1 Users
0 Reactions
2,005 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

With this function you can have the user select a directory using the new directory selector from Windows.

// MyNewFolder:=dtSelectFolder('c:');
// Select folder dialog (new style windows)
// Returns the same dir (StartDir) or the selected dir
//
// Add: Uses ShlObj !!!!
function dtSelectFolder(StartDir:string):string;
var browse_info: TBrowseInfo; folder: array[0..MAX_PATH] of char; find_context: PItemIDList;
begin 
  FillChar(browse_info,SizeOf(browse_info),#0); 
  browse_info.pszDisplayName := @folder[0]; 
  browse_info.lpszTitle := PChar('Choose your Folder'); 
  browse_info.ulFlags := BIF_RETURNONLYFSDIRS and BIF_BROWSEFORCOMPUTER and BIF_NEWDIALOGSTYLE; 
  browse_info.lpfn := nil; 
  find_context := SHBrowseForFolder(browse_info); 
  if Assigned(find_context) and SHGetPathFromIDList(find_context,folder) then 
    result := folder
  else 
    result := StartDir;
end;

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Screenshot


   
ReplyQuote
Share: