如题,代码如下:
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中就会有一个文件名不完整,求教高手解答原因,代码应该怎么改?
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中就会有一个文件名不完整,求教高手解答原因,代码应该怎么改?
...
CString fileName;
dlgFile.GetOFN().lpstrFile = fileName.GetBuffer(<very large number>);
dlgFile.GetOFN().nMaxFile = <very large number>;INT_PTR nResult = dlgFile.DoModal();
fileName.ReleaseBuffer();