如题,代码如下:
void CtestDlg::OnBnClickedButton1()
{
         m_control_list1.ResetContent();
int i=0;
TCHAR sz[] =_T("All File(*.*)|*.*|(*.bmp)|*.bmp|(*.jpg)|*.jpg|(*.tif)|*.tif||");
CFileDialog dlg(true,_T("*.*"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,sz);
int nRespand=dlg.DoModal();
if(nRespand==IDOK)
{
POSITION pos=dlg.GetStartPosition();
while(pos)
{
filePath=dlg.GetNextPathName(pos);
if(filePath.GetLength()==0)return;
m_control_list1.AddString(filePath);
i++;
}
                  m_control_list1.SetCurSel(i-1);
          }
}
每次选择超过10个文件时,listbox中就会有一个文件名不完整,求教高手解答原因,代码应该怎么改?

解决方案 »

  1.   

    断点跟下,每次插入ListBox的字符串是不是没问题
      

  2.   

    估计10个文件名的长度已经超过CFileDialog的默认缓冲区长度了,lz,你试试将缓冲区的长度设置大一些CFileDialog dlgFile(...);
    ...
    CString fileName;
    dlgFile.GetOFN().lpstrFile = fileName.GetBuffer(<very large number>);
    dlgFile.GetOFN().nMaxFile = <very large number>;INT_PTR nResult = dlgFile.DoModal();
    fileName.ReleaseBuffer();
      

  3.   

    listbox wideth should be longer