文件浏览对话框

    技术2024-10-26  22

      char fileName[MAX_PATH] = "";  //windef.h里面有这句#define MAX_PATH          260    CFileDialog dlgFile(TRUE);  //if use new style!    OSVERSIONINFO VersionInformation;       GetVersionEx(&VersionInformation);    if (VersionInformation.dwMajorVersion >= 5)        dlgFile.m_ofn.lStructSize = 88;  // new = 88   详见MSDN    else        dlgFile.m_ofn.lStructSize = 76;   // old = 76

     //do not use it ! dlgFile.m_ofn.Flags |= OFN_ENABLETEMPLATEHANDLE;     //dlgFile.m_ofn.Flags |= OFN_ENABLETEMPLATE;         // add our temp !    dlgFile.m_ofn.lpstrTitle = "浏览";     //dlgFile.m_ofn.lpstrFile = fileName;     dlgFile.m_ofn.Flags |= OFN_EXPLORER; //'Clip siblings' 'Child' 'None' '3Dlook' 'Control' 'Visible'    //dlgFile.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EX_OPEN); //=1547!    //dlgFile.m_ofn.hInstance=AfxGetInstanceHandle();     dlgFile.m_ofn.lpstrFilter = "程序/0*.exe/0所有文件/0*.*/0";    //dlgFile.m_ofn.lpstrDefExt = "txt";  // show     dlgFile.DoModal();#ifdef _DEBUG    afxDump << fileName << " /n";#endif 

    最新回复(0)