这个UFUN和NOPEN里没有对应的函数和类,要用C++的方法去做。

 1 #include "afxdialogex.h"//弹出选择文件夹对话框头文件
 2 #include "shlobj.h"//弹出选择文件夹对话框头文件
 3 using namespace std;
 4 
 5 
 6 string MyClass::OnSigBtnSelectInstallDir()//弹出选择文件夹对话框
 7 {
 8     BROWSEINFO  bi;
 9     bi.hwndOwner = NULL;
10     bi.pidlRoot = CSIDL_DESKTOP;//文件夹的根目录,此处为桌面
11     bi.pszDisplayName = NULL;
12     bi.lpszTitle = "请选择文件夹";//显示位于对话框左上部的提示信息
13     bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;//有新建文件夹按钮
14     bi.lpfn = NULL;
15     bi.iImage = 0;
16     LPITEMIDLIST pidl = SHBrowseForFolder(&bi);//调用选择对话框
17     string sFolder;
18     if (pidl != NULL)
19     {
20         TCHAR strFolder[MAX_PATH];
21         SHGetPathFromIDList(pidl, strFolder);
22         sFolder = strFolder;
23     }
24 
25     return sFolder;//选择文件夹返回值为路径,没选择文件夹返回值为空
26 }
27 
28 Caesar卢尚宇
29 2019年7月23日

NX二次开发-弹出选择文件夹对话框

附加说明2019年10月15日

如果头文件同时使用了

#include "afxdialogex.h"//弹出选择文件夹对话框头文件
#include "shlobj.h"//弹出选择文件夹对话框头文件
#include <windows.h>

这三个,请将#include <windows.h>放在最下边,如果放在上边会编译出错。

fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

 

相关文章:

  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案