How do I get a select folder/directory dialog in Rhino SDK C++?

How do I create a dialog where the user selects a directory/folder?
So far I have this, but it is not very user friendly/Rhino native

        HWND hwnd = RhinoApp().MainWnd();
        wchar_t* folderPath = nullptr;

        BROWSEINFO bi = { 0 };
        bi.hwndOwner = hwnd;
        LPITEMIDLIST pidl = SHBrowseForFolder(&bi);

        if (pidl != nullptr)
            // Get the folder path from the PIDL
            wchar_t path[MAX_PATH];
            if (SHGetPathFromIDList(pidl, path))
                folderPath = new wchar_t[MAX_PATH];
                wcscpy_s(folderPath, MAX_PATH, path);

            // Free the PIDL

        if (folderPath != nullptr)
            // Process the selected folder
            // Free the allocated memory
            delete[] folderPath;

Hi @fatecasino,

Try CRhinoUiDirDialog. There is also CRhinoFileUtilities::GetDirectory.

ā€“ Dale

Could I get any other style of dialog? I think this could be a bit difficult to use when the directory tree is a bit messy :slight_smile:

This is what the SDK offers. Anything else is up to you.

ā€” Dale

1 Like