这样干:static char BASED_CODE szFilter[]={"bmp files (*.bmp)|*.bmp|All files (*.*)|*.*||"};
CFileDialog dlg(TRUE,"BMP",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter);
if(dlg.DoModal()==IDOK)
{
CString fPathname=dlg.GetPathName();
m_pPathname=fPathname;

}

解决方案 »

  1.   

        openfile.m_ofn.Flags=OFN_ALLOWMULTISELECT; <---------要加上这个属性就可以了。
        openfile.m_ofn.lpstrFile=fname;
        openfile.m_ofn.nMaxFile=500;
        openfile.m_ofn.lpstrFilter="*.txt\0*.txt\0*.*\0*.*\0\0";
         
        openfile.m_ofn.Flags=OFN_ENABLEHOOK|OFN_ALLOWMULTISELECT; // 这样就行了
                             ^^^^^^^^^^^^^^
                              自己看看帮助吧!
      

  2.   

    不错,加上OFN_ENABLEHOOK后就不报错了,不知道这个参数是什麽意思,在msdn上并没有找到啊,另外,单选和多选弹出的对话框是不一样的,我想仍用单选那种类型的对话框,该怎麽改?
      

  3.   

    CFileDialog fd(TRUE,"jpg",NULL,OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Dicom files(*.jpg)|*.jpg||",NULL);
    DWORD MAXFILE = 2562; //2562 is the max
    fd.m_ofn.nMaxFile = MAXFILE;
    char pc[2562];
    fd.m_ofn.lpstrFile = pc;
    fd.m_ofn.lpstrFile[0] = NULL;
    if(fd.DoModal()==IDOK)
    {
    POSITION pos = fd.GetStartPosition();
    while (pos != NULL)
    {
    CString strFilePath=fd.GetNextPathName(pos);
                                 ............... }
    }
      

  4.   

    OFN_ALLOWMULTISELECT 
     Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface. 
    If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the filenames of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first filename, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. This format enables the Explorer-style dialogs to return long filenames that include spaces. For old-style dialog boxes, the directory and filename strings are separated by spaces and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames. If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the LBS_EXTENDEDSEL value. 
     
    OFN_ENABLEHOOK 
     Enables the hook function specified in the lpfnHook member 怎么会没有呢?