bbfu has asked for the wisdom of the Perl Monks concerning the following question:

I'm creating a simple application using Win32::GUI, and I find myself needing to allow the user to select one or more files. At first I thought that either Win32::GUI::BrowseForFolder() or Win32::GUI::GetOpenFileName() would do what I wanted. However, I would like the user to be able to select several files and / or directories at once, and neither of those methods appear to support that.

Is there any other Win32::GUI control that supports selecting of multiple files and / or directories at one time? I considered implementing one myself using TreeView but I would like to have it show the appropriate file icons for the different file types, etc, and it seems like it would be prohibitive to reimplement.

Or, perhaps, is there some undocumented option available to BrowseForFolder that would allow it to select mutliple file?

Thanks in advance.

bbfu
Black flowers blossom
Fearless on my breath

Replies are listed 'Best First'.
Re: Win32::GUI multi-file selection
by t0mas (Priest) on Sep 08, 2003 at 05:40 UTC
    The Win32::FileOp have the OFN_ALLOWMULTISELECT option for the open file dialog. Give it a try.

    /brother t0mas

      Yes, excellent. I discovered that module on my own as well, just before I read your reply. :) I think that's going to be the best solution I can manage. Thanks!

      bbfu
      Black flowers blossom
      Fearless on my breath

Re: Win32::GUI multi-file selection
by NetWallah (Canon) on Sep 08, 2003 at 04:15 UTC
    The standard Windows Common dialog control supports selecting multiple files. This is documented at this msdn URL.

    I have not attempted to call a com object via perl, but I imagine this should be fairly straightforward using one of the OLE moldules.

    For this functionality, I would suggest using the above MSDN method in preference to Win32::GUI with custom code because it is probably much easier, and a lot more standard.

      Ideally, I would like to use just one dialog for selecting both files and directories. Unfortunately, it appears that SHBrowseForFolder doesn't support selecting multiple files / directories, and GetOpenFilename doesn't support selecting folders (both at the system level). So it seems I'll have to use two different dialogs if I want to use the standard Windows dialogs. :(

      On a related note, I discovered that Win32::FileOp seems to allow access to the multiple-file selection ability of the OpenDialog, among many other nice and useful features. We should all thank Jenda for the very nice module. :)

      bbfu
      Black flowers blossom
      Fearless on my breath