Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone.I got stuck with the Openbox in win32.
I've read this article
(http://www.codeproject.com/Articles/3984/Customizing-the-quot-Browse-for-folder-quot-dialog).

That dude used a dialog box to call Folder Browser-box as it is visible on the main picture.
But I can't call it just pushing the VIEW button without using intermediate OpenBox.

HELP PLEASE.
And sorry for my wrong English, I hope you understand me/
Posted

1 solution

Hello,

Please see the code below. Note: I have failed to initialize/cleanup the shell memory need for the task. You may see an example of doing so here: To Browse a Folder OnButtonClick using Core WIN32[^]

Console Application
C++
#include <windows.h>
#include <shlobj.h>
#include <stdio.h>

int main()
{
    BROWSEINFO bInfo;
    LPITEMIDLIST pidl;
    char pszBuffer[MAX_PATH];

    bInfo.hwndOwner = NULL;
    bInfo.pidlRoot         =   NULL;
    bInfo.pszDisplayName   =   pszBuffer;
    bInfo.lpszTitle        =   "Select a Directory";
    bInfo.ulFlags          =   BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
    bInfo.lpfn             =   NULL;
    bInfo.lParam           =   0;

    if(pidl = SHBrowseForFolder(&bInfo))
    {
        // Copy the path directory to the buffer
        if(SHGetPathFromIDList(pidl,pszBuffer))
        {
            // pszBuffer now holds the directory path
            printf(("You selected the directory: %s\n"),pszBuffer);
        }
        else
            printf("Selected item not a folder\n");
    }
    else
        printf("User cancelled OR failure with: SHBrowseForFolder(&bInfo);");

    return 0;
}
 
Share this answer
 
v2
Comments
JOHN 602 13-May-12 5:22am    
THANX for you answer I very appreciate you for your attention////
I've already tried your code... it helps me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900