MFC文件夹对话框

void CPrintPortDlg::OnBnClickedMfcbutton1()
{
CString sFolderPath;
BROWSEINFO bi;
char Buffer[MAX_PATH];
bi.hwndOwner = NULL;
bi.pidlRoot =NULL;
bi.pszDisplayName = Buffer;
bi.lpszTitle = "変換元フォームフォルダの選択";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.iImage=IDR_MAINFRAME;
LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);
if (pIDList) {
SHGetPathFromIDList(pIDList, Buffer);
sFolderPath = Buffer;
}
GetDlgItem(IDC_EDIT1)->SetWindowText(sFolderPath);
BrowseDir(sFolderPath,1);
HTREEITEM hItem,hSubItem;
hItem = myTree.InsertItem("Parent1",TVI_ROOT);
hSubItem = myTree.InsertItem("Child1_1",hItem);
hSubItem = myTree.InsertItem("Child1_2",hItem,hSubItem);
LPMALLOC lpMalloc;
if(FAILED(SHGetMalloc(&lpMalloc))) return;
lpMalloc->Free(pIDList);
lpMalloc->Release();
}

你可能感兴趣的:(C++,MFC文件夹对话框)