SelectFolderEx() - new dialog on Win Vista+

Post your working scripts, libraries and tools
just me
Posts: 7408
Joined: 02 Oct 2013, 08:51
Location: Germany

SelectFolderEx() - new dialog on Win Vista+

13 Jun 2016, 04:32

Related: viewtopic.php?f=5&t=18764

The function is using the Common Item Dialog to select folders on Win Vista+ providing a almost identical UI for selecting files and folders (at least on WIn 10 here):

Code: Select all

; ==================================================================================================================================
; Shows a dialog to select a folder.
; Depending on the OS version the function will use either the built-in FileSelectFolder command (XP and previous)
; or the Common Item Dialog (Vista and later).
; Parameter:
;     StartingFolder -  the full path of a folder which will be preselected.
;     Prompt         -  a text used as window title (Common Item Dialog) or as text displayed withing the dialog.
;     ----------------  Common Item Dialog only:
;     OwnerHwnd      -  HWND of the Gui which owns the dialog. If you pass a valid HWND the dialog will become modal.
;     BtnLabel       -  a text to be used as caption for the apply button.
;  Return values:
;     On success the function returns the full path of selected folder; otherwise it returns an empty string.
; MSDN:
;     Common Item Dialog -> msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
;     IFileDialog        -> msdn.microsoft.com/en-us/library/bb775966%28v=vs.85%29.aspx
;     IShellItem         -> msdn.microsoft.com/en-us/library/bb761140%28v=vs.85%29.aspx
; ==================================================================================================================================
SelectFolderEx(StartingFolder := "", Prompt := "", OwnerHwnd := 0, OkBtnLabel := "") {
   Static OsVersion := DllCall("GetVersion", "UChar")
        , IID_IShellItem := 0
        , InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
                  & DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
        , Show := A_PtrSize * 3
        , SetOptions := A_PtrSize * 9
        , SetFolder := A_PtrSize * 12
        , SetTitle := A_PtrSize * 17
        , SetOkButtonLabel := A_PtrSize * 18
        , GetResult := A_PtrSize * 20
   SelectedFolder := ""
   If (OsVersion < 6) { ; IFileDialog requires Win Vista+, so revert to FileSelectFolder
      FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
      Return SelectedFolder
   }
   OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
   If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
      Return ""
   VTBL := NumGet(FileDialog + 0, "UPtr")
   ; FOS_CREATEPROMPT | FOS_NOCHANGEDIR | FOS_PICKFOLDERS
   DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00002028, "UInt")
   If (StartingFolder <> "")
      If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
         DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
   If (Prompt <> "")
      DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
   If (OkBtnLabel <> "")
      DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")
   If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt") {
      If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
         GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
         If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
            SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
         ObjRelease(ShellItem)
   }  }
   If (FolderItem)
      ObjRelease(FolderItem)
   ObjRelease(FileDialog)
   Return SelectedFolder
}
Edit:
License: The Unlicense (for details see unlicense.org)
User avatar
Xtra
Posts: 1998
Joined: 02 Oct 2015, 12:15

Re: SelectFolderEx() - new dialog on Win Vista+

13 Jun 2016, 06:34

Looks good thanks!
User avatar
jballi
Posts: 625
Joined: 29 Sep 2013, 17:34

Re: SelectFolderEx() - new dialog on Win Vista+

20 Jul 2016, 14:35

Looks useful. Thanks.
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

Re: SelectFolderEx() - new dialog on Win Vista+

04 Oct 2016, 11:32

That's really something
Thumbs up!
User avatar
DataLife
Posts: 358
Joined: 29 Sep 2013, 19:52

Re: SelectFolderEx() - new dialog on Win Vista+

06 Oct 2016, 14:55

I have replaced all FileSelectFolder with SelectFolderEx in my program SavePictureAs.

Do I have your permission to release SavePictureAs with SelectFolderEx with proper credit given?
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
just me
Posts: 7408
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SelectFolderEx() - new dialog on Win Vista+

06 Oct 2016, 15:12

Added license. You have, even without credit!
User avatar
DataLife
Posts: 358
Joined: 29 Sep 2013, 19:52

Re: SelectFolderEx() - new dialog on Win Vista+

06 Oct 2016, 16:58

just me wrote:Added license. You have, even without credit!
thanks
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
rommmcek
Posts: 1123
Joined: 15 Aug 2014, 15:18

Re: SelectFolderEx() - new dialog on Win Vista+

24 Nov 2019, 13:14

Awesome function!

Here is my contribution, so that after click on the TreeView (on the left hand side of the dialog), Select Folder button can be applied immediately:

Code: Select all

If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
	GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
       	 If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
            SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
        !SelectedFolder? DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", SelectedFolder, "UInt"): "" ; added
        ;InStr(FileExist("C:\Users\RRR\My Ahk-s"), "D", 1)? "": SelectedFolder:= "" ; not needed, Dialog will propmpt by itself if folder doesn't exist
        ObjRelease(ShellItem)
}
P.s: DllCall in the added ternary, is bluntly copy-pasted from the line above in this function. (First I used ControlGetText, then I noticed the script already refers to value in that control)

EDIT3: Just had an issue if #Warn is present in the script: "Warning: This variable has not been assigned a value.", so I had to add Local ShellItem:= StrPtr:= FolderItem:= "" to the starting declaration of the function to prevent it.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SelectFolderEx() - new dialog on Win Vista+

04 May 2020, 04:18

Hello!

Is it possible to have this dialog transformed into a files selector with filters set?

EDIT: After reading about the APIs on MSDN, it should be possible.... I would like some help with this, in particular, setting filters or «file types».

Thank you .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
just me
Posts: 7408
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SelectFolderEx() - new dialog on Win Vista+

04 May 2020, 04:56

I'm not sure what you want to do. AHK's FileSelectFile is already using the 'Common Item Dialog' on newer Windows versions.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SelectFolderEx() - new dialog on Win Vista+

04 May 2020, 05:38

just me wrote:
04 May 2020, 04:56
I'm not sure what you want to do. AHK's FileSelectFile is already using the 'Common Item Dialog' on newer Windows versions.
It does not allow multiple filters:, like Images (*.jpg; *.png) and Docs (*.rtf; *.txt).... this is what i desperately need... It would be a great help this.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
jballi
Posts: 625
Joined: 29 Sep 2013, 17:34

Re: SelectFolderEx() - new dialog on Win Vista+

04 May 2020, 06:06

robodesign wrote:
04 May 2020, 05:38
just me wrote:
04 May 2020, 04:56
I'm not sure what you want to do. AHK's FileSelectFile is already using the 'Common Item Dialog' on newer Windows versions.
It does not allow multiple filters:, like Images (*.jpg; *.png) and Docs (*.rtf; *.txt).... this is what i desperately need... It would be a great help this.
The Dlg2 Common Dialogs library hasn't been updated in a few years but it does allow for multiple filters to be set. It might be useful until this function is updated. The "multiple filters" logic in the library might could be used in this function.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SelectFolderEx() - new dialog on Win Vista+

04 May 2020, 08:37

jballi wrote:
04 May 2020, 06:06
robodesign wrote:
04 May 2020, 05:38
just me wrote:
04 May 2020, 04:56
I'm not sure what you want to do. AHK's FileSelectFile is already using the 'Common Item Dialog' on newer Windows versions.
It does not allow multiple filters:, like Images (*.jpg; *.png) and Docs (*.rtf; *.txt).... this is what i desperately need... It would be a great help this.
The Dlg2 Common Dialogs library hasn't been updated in a few years but it does allow for multiple filters to be set. It might be useful until this function is updated. The "multiple filters" logic in the library might could be used in this function.
Thank you very much . I think it is enough for my needs.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SelectFolderEx() - new dialog on Win Vista+

07 May 2020, 06:45

Hello!

I extended the function to allow adding a combo-box/list into the dialog, based on a different thread i found some time ago... And also custom places /folders list.

Code: Select all

SelectFolderEx(StartingFolder:="", Prompt:="", OwnerHwnd:=0, OkBtnLabel:="", comboList:="", desiredDefault:=1, comboLabel:="", CustomPlaces:="", pickFoldersOnly:=1) {
; ==================================================================================================================================
; Shows a dialog to select a folder.
; Depending on the OS version the function will use either the built-in FileSelectFolder command (XP and previous)
; or the Common Item Dialog (Vista and later).
;
; Parameter:
;     StartingFolder -  the full path of a folder which will be preselected.
;     Prompt         -  a text used as window title (Common Item Dialog) or as text displayed withing the dialog.
;     ----------------  Common Item Dialog only:
;     OwnerHwnd      -  HWND of the Gui which owns the dialog. If you pass a valid HWND the dialog will become modal.
;     BtnLabel       -  a text to be used as caption for the apply button.
;     comboList      -  a string with possible drop-down options, separated by `n [new line]
;     desiredDefault -  the default selected drop-down row
;     comboLabel     -  the drop-down label to display
;     CustomPlaces   -  custom directories that will be displayed in the left pane of the dialog; missing directories will be omitted; a string separated by `n [newline]
;     pickFoldersOnly - boolean option [0, 1]
;
;  Return values:
;     On success the function returns an object with the full path of the selected/file folder
;     and combobox selected [if any]; otherwise it returns an empty string.
;
; MSDN:
;     Common Item Dialog -> msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
;     IFileDialog        -> msdn.microsoft.com/en-us/library/bb775966%28v=vs.85%29.aspx
;     IShellItem         -> msdn.microsoft.com/en-us/library/bb761140%28v=vs.85%29.aspx
; ==================================================================================================================================
; Source https://www.autohotkey.com/boards/viewtopic.php?f=6&t=18939
; by «just me»
; modified by Marius Șucan on: vendredi 8 mai 2020
; to allow ComboBox and CustomPlaces
;
; options flags
; FOS_OVERWRITEPROMPT  = 0x2,
; FOS_STRICTFILETYPES  = 0x4,
; FOS_NOCHANGEDIR  = 0x8,
; FOS_PICKFOLDERS  = 0x20,
; FOS_FORCEFILESYSTEM  = 0x40,
; FOS_ALLNONSTORAGEITEMS  = 0x80,
; FOS_NOVALIDATE  = 0x100,
; FOS_ALLOWMULTISELECT  = 0x200,
; FOS_PATHMUSTEXIST  = 0x800,
; FOS_FILEMUSTEXIST  = 0x1000,
; FOS_CREATEPROMPT  = 0x2000,
; FOS_SHAREAWARE  = 0x4000,
; FOS_NOREADONLYRETURN  = 0x8000,
; FOS_NOTESTFILECREATE  = 0x10000,
; FOS_HIDEMRUPLACES  = 0x20000,
; FOS_HIDEPINNEDPLACES  = 0x40000,
; FOS_NODEREFERENCELINKS  = 0x100000,
; FOS_OKBUTTONNEEDSINTERACTION  = 0x200000,
; FOS_DONTADDTORECENT  = 0x2000000,
; FOS_FORCESHOWHIDDEN  = 0x10000000,
; FOS_DEFAULTNOMINIMODE  = 0x20000000,
; FOS_FORCEPREVIEWPANEON  = 0x40000000,
; FOS_SUPPORTSTREAMABLEITEMS  = 0x80000000

; IFileDialog vtable offsets
; 0   QueryInterface
; 1   AddRef 
; 2   Release 
; 3   Show 
; 4   SetFileTypes 
; 5   SetFileTypeIndex 
; 6   GetFileTypeIndex 
; 7   Advise 
; 8   Unadvise 
; 9   SetOptions 
; 10  GetOptions 
; 11  SetDefaultFolder 
; 12  SetFolder 
; 13  GetFolder 
; 14  GetCurrentSelection 
; 15  SetFileName 
; 16  GetFileName 
; 17  SetTitle 
; 18  SetOkButtonLabel 
; 19  SetFileNameLabel 
; 20  GetResult 
; 21  AddPlace 
; 22  SetDefaultExtension 
; 23  Close 
; 24  SetClientGuid 
; 25  ClearClientData 
; 26  SetFilter


   Static OsVersion := DllCall("GetVersion", "UChar")
        , IID_IShellItem := 0
        , InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
                  & DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
        , Show := A_PtrSize * 3
        , SetOptions := A_PtrSize * 9
        , SetFolder := A_PtrSize * 12
        , SetTitle := A_PtrSize * 17
        , SetOkButtonLabel := A_PtrSize * 18
        , GetResult := A_PtrSize * 20
        , ComDlgObj := {COMDLG_FILTERSPEC: ""}

   SelectedFolder := ""
   If (OsVersion<6)
   {
      ; IFileDialog requires Win Vista+, so revert to FileSelectFolder
      FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
      Return SelectedFolder
   }

   OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
   If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
      Return ""

   VTBL := NumGet(FileDialog + 0, "UPtr")
   dialogOptions := 0x8 | 0x800  ;  FOS_NOCHANGEDIR | FOS_PATHMUSTEXIST
   dialogOptions |= (pickFoldersOnly=1) ? 0x20 : 0x1000    ; FOS_PICKFOLDERS : FOS_FILEMUSTEXIST

   DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", dialogOptions, "UInt")
   If StartingFolder
   {
      If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
         DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
   }

   If Prompt
      DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
   If OkBtnLabel
      DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")

   If CustomPlaces
   {
      Loop, Parse, CustomPlaces, `n
      {
          If InStr(FileExist(A_LoopField), "D")
          {
             foo := 1, Directory := A_LoopField
             DllCall("Shell32.dll\SHParseDisplayName", "UPtr", &Directory, "Ptr", 0, "UPtrP", PIDL, "UInt", 0, "UInt", 0)
             DllCall("Shell32.dll\SHCreateShellItem", "Ptr", 0, "Ptr", 0, "UPtr", PIDL, "UPtrP", IShellItem)
             ObjRawSet(ComDlgObj, IShellItem, PIDL)
             ; IFileDialog::AddPlace method
             ; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775946(v=vs.85).aspx
             DllCall(NumGet(NumGet(FileDialog+0)+21*A_PtrSize), "UPtr", FileDialog, "UPtr", IShellItem, "UInt", foo)
          }
      }
   }

   If (comboList && comboLabel)
   {
      Try If ((FileDialogCustomize := ComObjQuery(FileDialog, "{e6fdd21a-163f-4975-9c8c-a69f1ba37034}")))
      {
         groupId := 616 ; arbitrarily chosen IDs
         comboboxId := 93270
         DllCall(NumGet(NumGet(FileDialogCustomize+0)+26*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", groupId, "WStr", comboLabel) ; IFileDialogCustomize::StartVisualGroup
         DllCall(NumGet(NumGet(FileDialogCustomize+0)+6*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", comboboxId) ; IFileDialogCustomize::AddComboBox
         ; DllCall(NumGet(NumGet(FileDialogCustomize+0)+19*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", comboboxId, "UInt", itemOneId, "WStr", "Current folder") ; IFileDialogCustomize::AddControlItem
         
         entriesArray := []
         Loop, Parse, comboList,`n
         {
             Random, varA, 2, 900
             Random, varB, 2, 900
             thisID := varA varB
             If A_LoopField
             {
                If (A_Index=desiredDefault)
                   desiredIDdefault := thisID

                entriesArray[thisId] := A_LoopField
                DllCall(NumGet(NumGet(FileDialogCustomize+0)+19*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", comboboxId, "UInt", thisID, "WStr", A_LoopField)
             }
         }

         DllCall(NumGet(NumGet(FileDialogCustomize+0)+25*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", comboboxId, "UInt", desiredIDdefault) ; IFileDialogCustomize::SetSelectedControlItem
         DllCall(NumGet(NumGet(FileDialogCustomize+0)+27*A_PtrSize), "Ptr", FileDialogCustomize) ; IFileDialogCustomize::EndVisualGroup
      }

   }

   If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt")
   {
      If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt")
      {
         GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
         If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
            SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)

         ObjRelease(ShellItem)
         if (FileDialogCustomize)
         {
            if (DllCall(NumGet(NumGet(FileDialogCustomize+0)+24*A_PtrSize), "Ptr", FileDialogCustomize, "UInt", comboboxId, "UInt*", selectedItemId) == 0)
            { ; IFileDialogCustomize::GetSelectedControlItem
               if selectedItemId
                  thisComboSelected := entriesArray[selectedItemId]
            }   
         }
      }
   }
   If (FolderItem)
      ObjRelease(FolderItem)

   if (FileDialogCustomize)
      ObjRelease(FileDialogCustomize)

   ObjRelease(FileDialog)
   r := []
   r.SelectedDir := SelectedFolder
   r.SelectedCombo := thisComboSelected
   Return r
}
I hope someone finds this helpful.

Best regards, Marius.
Last edited by robodesign on 09 May 2020, 15:59, edited 2 times in total.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: SelectFolderEx() - new dialog on Win Vista+

07 May 2020, 08:38

Hi Marius,
Would you mind giving an example of creating the combo box's list and then using a selection from it?
I can see that you can create the list either with a continuation section or adding newlines in a string to separate the entries, and the combo box appears just fine, but I'm uncertain as to how to proceed from there.
Nice work!
Regards,
burque505
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SelectFolderEx() - new dialog on Win Vista+

07 May 2020, 09:21

The function returns the object which contains both the selected folder and the selected entry from the combo list.

In my image viewer I create a list of previously opened folders within the application and I offer users the ability to quickly access them without having to browse to them. When the user selects a folder from the combo box list I ignore the current folder of the dialog box, I use the one selected in the list. In this instance, the group name is "history" and the default, first entry is... "use current folder", such that I don't force users to select from history only ^_^.

Another use case would be to have options like "open recursively" or anything else.... It's up to you what options you want to have and how to proceed when the user selects this or that.

Now, I'd only like to have it work with file filters as well...

I hope my reply is clear enough for you.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: SelectFolderEx() - new dialog on Win Vista+

07 May 2020, 09:53

Yes, that's clear now. An admittedly absurd example:

Code: Select all

combolist =
(
one banana
two banana
three banana
)
obj := SelectFolderEx("","Primate", 0, "Good primate!", combolist, 1, "Cheetah want ")

msgbox % obj.SelectedDir ; selected directory
msgbox % obj.SelectedCombo ; combo selection
exitapp
Thank, Marius!
Regards,
burque505
User avatar
SirSocks
Posts: 207
Joined: 26 Oct 2018, 08:14

Re: SelectFolderEx() - new dialog on Win Vista+

08 May 2020, 07:29

This is perfect! Thank you very much!

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Google [Bot] and 23 guests