FileDialog 打开很多文件是不是有限制的?
我一次选择很多文件的时候,大概是18个以上,就自动退出FileDialog 了,有什么办法解决呢?int a = dlg.domodel();a = 2了。

解决方案 »

  1.   

    参数里面可以设置最大数目的~你设置足够的buffer就好了~typedef struct tagOFN { 
      DWORD         lStructSize; 
      HWND          hwndOwner; 
      HINSTANCE     hInstance; 
      LPCTSTR       lpstrFilter; 
      LPTSTR        lpstrCustomFilter; 
      DWORD         nMaxCustFilter; 
      DWORD         nFilterIndex; 
      LPTSTR        lpstrFile; 
      DWORD         nMaxFile; 
      LPTSTR        lpstrFileTitle; 
      DWORD         nMaxFileTitle; 
      LPCTSTR       lpstrInitialDir; 
      LPCTSTR       lpstrTitle; 
      DWORD         Flags; 
      WORD          nFileOffset; 
      WORD          nFileExtension; 
      LPCTSTR       lpstrDefExt; 
      LPARAM        lCustData; 
      LPOFNHOOKPROC lpfnHook; 
      LPCTSTR       lpTemplateName; 
    #if (_WIN32_WINNT >= 0x0500)
      void *        pvReserved;
      DWORD         dwReserved;
      DWORD         FlagsEx;
    #endif // (_WIN32_WINNT >= 0x0500)
    } OPENFILENAMEnMaxFile
    Specifies the size, in TCHARs, of the buffer pointed to by lpstrFile. For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters. The buffer must be large enough to store the path and file name string or strings, including the terminating NULL character. The GetOpenFileName and GetSaveFileName functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256 characters long.
      

  2.   

    打开多个文件的数目是没有限制的,但缓冲区需要自己提供,例如:
    CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, 
        _T("All files (*.*)|*.*||"));    char cBuffer[102400]; // 100 KB    cBuffer[0]='\0';
        dlg.m_ofn.lpstrFile=cBuffer;
        dlg.m_ofn.nMaxFile=sizeof(cBuffer); // buffer size