Hi all,

This patch should allow the user to show "New Folder/Make New Folder" for win32 when using TSelectDirectoryDialog.

User should set the Options with "ofOldStyleDialog" to false to make this to work though.

Regards,
YH
Index: lcl/interfaces/win32/win32extra.pas
===================================================================
--- lcl/interfaces/win32/win32extra.pas (revision 12112)
+++ lcl/interfaces/win32/win32extra.pas (working copy)
@@ -94,7 +94,15 @@
   OFN_ENABLESIZING = $800000;
   
   { BrowseForFolder dialog}
+  // http://msdn2.microsoft.com/en-us/library/ms538017.aspx
   BIF_RETURNONLYFSDIRS = 1;
+  BIF_NEWDIALOGSTYLE = $40;
+    //Version 5.0. Use the new user interface. Setting this flag provides the
+    //user with a larger dialog box that can be resized. The dialog box has
+    //several new capabilities, including: drag-and-drop capability within the
+    //dialog box, reordering, shortcut menus, new folders, delete, and other
+    //shortcut menu commands. To use this flag, you must call OleInitialize or
+    //CoInitialize before calling SHBrowseForFolder.
 
   BFFM_INITIALIZED = 1;
   BFFM_SELCHANGED = 2;
Index: lcl/interfaces/win32/win32wsdialogs.pp
===================================================================
--- lcl/interfaces/win32/win32wsdialogs.pp      (revision 12112)
+++ lcl/interfaces/win32/win32wsdialogs.pp      (working copy)
@@ -639,16 +639,19 @@
   end;
   Result := 0;
 end;
-
 class function TWin32WSSelectDirectoryDialog.CreateHandle(const ACommonDialog: 
TCommonDialog): THandle;
 var
   bi : TBrowseInfo;
+  Options: TOpenOptions;
   Buffer : PChar;
   iidl : PItemIDList;
   InitialDir: string;
 begin
   Buffer := CoTaskMemAlloc(MAX_PATH);
   InitialDir := TSelectDirectoryDialog(ACommonDialog).FileName;
+  
+  Options := TSelectDirectoryDialog(ACommonDialog).Options;
+  
   if length(InitialDir)=0 then
     InitialDir := TSelectDirectoryDialog(ACommonDialog).InitialDir;
   if length(InitialDir)>0 then begin
@@ -666,6 +669,9 @@
     pszDisplayName := Buffer;
     lpszTitle := PChar(ACommonDialog.Title);
     ulFlags := BIF_RETURNONLYFSDIRS;
+    if not (ofOldStyleDialog in Options) then begin
+       ulFlags := ulFlags + BIF_NEWDIALOGSTYLE;
+    end;
     lpfn := @BrowseForFolderCallback;
     // this value will be passed to callback proc as lpData
     lParam := LclType.LParam(PChar(InitialDir));

Reply via email to