1 #include <uf.h> 2 #include <uf_ui.h> 3 #include <string> 4 5 using namespace std; 6 7 string OpenDirectionDialog(char* lpszDefault) 8 { 9 //去除字符串末尾的\; 10 int nlast = strlen(lpszDefault) - 1; 11 string strDefault = lpszDefault; 12 if (strDefault.at(nlast) == ‘\\‘) 13 strDefault.at(nlast) = ‘\0‘; 14 15 int nResponse = 0; 16 char lpszDefaultFile[256] = ""; 17 char lpszFileFiter[133] = "Direction"; 18 char lpszFilePath[256] = ""; 19 //设置初始目录; 20 sprintf_s(lpszDefaultFile, 256, "%s\\%ss", strDefault.c_str(), lpszFileFiter); 21 UF_UI_create_filebox("选择一个目录", "目录浏览器", lpszFileFiter, lpszDefaultFile, lpszFilePath, &nResponse); 22 23 string strPath, strPathSel; 24 if (nResponse == UF_UI_OK) 25 { 26 strPath = lpszFilePath; 27 //去除Direction; 28 int nPos = strPath.rfind("\\"); 29 strPathSel = strPath.substr(0, nPos); 30 } 31 else 32 { 33 strPathSel = ""; 34 } 35 36 return strPathSel;//选择文件夹返回值为路径,没选择文件夹返回值为空 37 }
原文地址:https://www.cnblogs.com/nxopen2018/p/11829577.html
时间: 2024-10-09 09:18:48