最新的WTL库中添加了对Vista/Win7新风格文件对话框API的封装,使用起来非常方便。

1.选择文件对话框:

//#include <atldlgs.h>
COMDLG_FILTERSPEC filterSpecs[] = 
{
    {_T("Text documents(*.txt)"),_T("*.txt")},
    {_T("MS Word documents(*.doc|*.docx)"),_T("*.doc;*.docx")},
    {_T("All documents(*.*)"),_T("*.*")}
};
CShellFileOpenDialog fileOpenDlg(
    NULL,
    FOS_FORCEFILESYSTEM|FOS_FILEMUSTEXIST|FOS_PATHMUSTEXIST,
   _T("txt"),
    filterSpecs,
    _countof(filterSpecs));
fileOpenDlg.DoModal(m_hWnd);
CString filePath;
fileOpenDlg.GetFilePath(filePath);
//MessageBox(filePath,_T("File path"),MB_OK|MB_ICONINFORMATION);
WTL-Open file dialog of new vista/win7 style

2.选择文件夹对话框

CShellFileOpenDialog fileOpenDlg(
    NULL,
    FOS_FORCEFILESYSTEM|FOS_PATHMUSTEXIST|FOS_PICKFOLDERS);
fileOpenDlg.DoModal(m_hWnd);
CString folderPath;
fileOpenDlg.GetFilePath(folderPath);
MessageBox(folderPath,_T("Folder path"),MB_OK|MB_ICONINFORMATION);
WTL-Open file dialog of new vista/win7 style

相关文章:

  • 2021-04-22
  • 2021-12-07
  • 2021-12-25
  • 2021-09-11
  • 2022-02-10
  • 2021-07-18
  • 2021-08-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
相关资源
相似解决方案