首页 > 代码库 > 选择文件或文件夹对话框---带有回调函数
选择文件或文件夹对话框---带有回调函数
QString FileDialogUtils::getSaveFileDir(const QString& tips/* = QString()*/, QWidget* parent/* = 0*/) { QString result; BROWSEINFO bi = {0}; if(!tips.isEmpty()) { bi.lpszTitle = tips.utf16(); } if(parent) { bi.hwndOwner = (HWND)parent->winId(); } //BIF_BROWSEINCLUDEFILES | // 用来显示文件 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; bi.lpfn = BrowseCallbackProc; // 回调函数 LPITEMIDLIST pidl = SHBrowseForFolder(&bi); if (pidl != NULL) { // else, user canceled TCHAR szPath[MAX_PATH]; if(SHGetPathFromIDList(pidl, szPath)) { result = QString::fromUtf16(szPath); } } return result;}INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { LPITEMIDLIST tmp = (LPITEMIDLIST)pData; QString result; switch(uMsg) { case BFFM_INITIALIZED: //SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szdir); break; case BFFM_SELCHANGED: // Set the status window to the currently selected path. if (tmp != NULL) { // else, user canceled TCHAR szPath[MAX_PATH]; if(SHGetPathFromIDList(tmp, szPath)) { result = QString::fromUtf16(szPath); } } break; } return 0;}
选择文件或文件夹对话框---带有回调函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。