我想做个树视对话框,用于选择系统的目录
比如我们在播放音乐时想播放一个目录的歌曲时,可以通过打开一个目录来实现
各位大哥可以给点提示吗?
最后有代码???

解决方案 »

  1.   

    CString sOutputDir;
    LPMALLOC pMalloc;
    // Gets the Shell's default allocator
    if (::SHGetMalloc(&pMalloc) == NOERROR)
    {
    BROWSEINFO bi;
    char pszBuffer[MAX_PATH];
    LPITEMIDLIST pidl; bi.hwndOwner = NULL;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = pszBuffer;
    bi.lpszTitle = _T("选择导入的目录...");
    bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
    bi.lpfn = NULL;
    bi.lParam = 0; // This next call issues the dialog box.
    if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
    {
    if (::SHGetPathFromIDList(pidl, pszBuffer))
    sOutputDir = pszBuffer;
    // Free the PIDL allocated by SHBrowseForFolder.
    pMalloc->Free(pidl);
    }
    else
    return; // Release the shell's allocator.
    pMalloc->Release();
    }