locked
SHBrowseForFolder Browser info flag BIF_EDITBOX edit control in the browse dialog box leaves the newly created folder in non edit mode RRS feed

  • Question

  • Hi Team,

    Has i'm using SHBrowseForFolder in my pretty old projects, i had seen recently "Make New Folder" button inside the folder dialog creates and leaves the newly created folder in non edit mode, even after setting up all the flags.

    here goes my code:

    BOOL CShellBrowser::SelectFolder()
    {
    LPMALLOC pMalloc;
    BOOL bRC = FALSE;

    // Get the Shell's default allocator.
    if (SUCCEEDED(::SHGetMalloc(&pMalloc)))
    {
    LPITEMIDLIST pidl;

    // Setup the BROWSEINFO struct for browse call.
    m_BrowseInfo.pszDisplayName = m_szDirectory;
    m_BrowseInfo.lpszTitle = m_szTitle;
    m_BrowseInfo.lpfn = BrowseCallbackProc;
    m_BrowseInfo.ulFlags = BIF_EDITBOX |BIF_USENEWUI |BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT;

    // Issue the browse dialog box.
    if ((pidl = ::SHBrowseForFolder(&m_BrowseInfo)) != NULL)
    {
    if (SUCCEEDED(::SHGetPathFromIDList(pidl, m_szDirectory)))
    bRC = TRUE;

    // Free the PIDL allocated by SHBrowseForFolder.
    pMalloc->Free(pidl);
    }

    // Release the shell's allocator.
    pMalloc->Release();
    }

    return bRC;
    }

    // for Browse Callback function code

    INT CALLBACK BrowseCallbackProc(HWND hwnd, 
                                    UINT uMsg,
                                    LPARAM lp, 
                                    LPARAM pData) 
    {
       TCHAR szDir[MAX_PATH];

       switch(uMsg) 
       {
       case BFFM_INITIALIZED: 
          if (GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir))
          {
             // WParam is TRUE since you are passing a path.
             // It would be FALSE if you were passing a pidl.
             SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
          }
          break;

       case BFFM_SELCHANGED: 
          // Set the status window to the currently selected path.
          if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
          {
             SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir);
          }
          break;
       }
       return 0;
    }

    i'm seeing this problem only if create an new folder on desktop directly, but not on creating inside any other sub folders.

    please let me know, if something is missing.

    Thanks,

    Avinash

    Tuesday, July 14, 2020 6:00 AM

All replies

  • Hello Vavin_Avi,

    I test on Windows 10 1909 and observed that:

    1. When creating a new folder on desktop, it is initial in edit mode but immediately turns into non-edit mode automatically.
    2. When it goes into non-edit mode you can still edit it by, for example, right click on the folder and select "Rename".

    Could you confirm if this is the issue you are talking about?

    If yes, it works on Windows 10 2004 for me. Maybe you can have a try.

    Best regards,

    Rita


    "Win32 API" forum will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "Win32 API" forum’s new home on Microsoft Q&A !
    For more information, please refer to the sticky post.

    Tuesday, July 14, 2020 9:05 AM
  • Hi Rita Han,

    yes this the exact behavior i'm seeing in my machine. 

    1. When creating a new folder on desktop, it is initial in edit mode but immediately turns into non-edit mode automatically.
    2. When it goes into non-edit mode you can still edit it by, for example, right click on the folder and select "Rename".

    Thank you so much for your help!.

    Is their any other way to resolve this issue ??? rather than upgrading to 2004 version ?

    Thanks,

    Vavin

    Tuesday, July 14, 2020 2:03 PM
  • Hello Vavin_Avi,

    Thanks for your confirmation.

    A workaround maybe using another location instead of desktop or right clicking and selecting "Rename" to turn it into edit mode again.

    Best regards,

    Rita


    "Win32 API" forum will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "Win32 API" forum’s new home on Microsoft Q&A !
    For more information, please refer to the sticky post.

    Wednesday, July 15, 2020 7:07 AM
  • hi Rita,

    Yes, this workaround i have already known. Thanks for that!.

    But do you have any idea, why exactly this kind of behavior is observed in this specific Windows 10 Operating System. 

    Is this due to specific API support is deprecated or any technical reason behind this.

    Thanks,

    Avinash

    Thursday, July 30, 2020 5:49 AM
  • Hello Vavin_Avi,

    I have reported this issue internally for a further investigation and update to you if there is any progress. Thank you for bringing this to our attention.

    [This “Windows Desktop SDK” Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details.]

    Best regards,

    Rita


    "Win32 API" forum will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "Win32 API" forum’s new home on Microsoft Q&A !
    For more information, please refer to the sticky post.

    Thursday, July 30, 2020 7:47 AM
  • Thanks, please keep me posted if any useful information found.

    Regards,

    Vavin

    Monday, August 3, 2020 7:12 AM