sqweek / dialog

Simple cross-platform dialog API for go-lang
ISC License
493 stars 76 forks source link

Updated Windows Folder Picker #61

Closed dougwinsby closed 2 years ago

dougwinsby commented 2 years ago

The Microsoft docs say to use IFileDialog instead of SHBrowseForFolderA:

"For Windows Vista or later, it is recommended that you use IFileDialog with the FOS_PICKFOLDERS option rather than the SHBrowseForFolder function. This uses the Open Files dialog in pick folders mode and is the preferred implementation."

https://docs.microsoft.com/en-us/windows/win32/shell/common-file-dialog https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifiledialog-setoptions https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions

It doesn't look to me like the underlying win32 library you're using (github.com/TheTitanrain/w32) supports this COM interface, so this feature might be difficult to implement.

Here is a sample in c++ to show what is required:

https://cpp.hotexamples.com/examples/-/IFileDialog/Show/cpp-ifiledialog-show-method-examples.html

Here is the only Go project I could (easily) find that uses "CoCreateInstance" (e.g. wrappers/objbase.go):

https://github.com/winlabs/gowin32

Sorry I don't have more time to offer code for a PR. It looks like something that might be fun to work on.

Thank you for this great project.

sqweek commented 2 years ago

Thanks for the references. On first glance it looks like a decent amount of extra complexity for little to no benefit -- most of the advantages listed for the Common Item Dialog are well out of scope for this project (although being able to set the starting directory without a callback would have been a blessing). Admittedly I'm not at all familiar with COM, which doesn't help matters.

Was there a particular motivation behind the suggestion?

dougwinsby commented 2 years ago

It just makes the Windows app look old-school. Maybe the biggest feature I miss is the ability to copy/paste a folder from File Explorer.

I can see how it would be an extensive change, though. I'll close this issue (and maybe revisit if I ever come up with something more helpful). Thanks for looking into it.