bsp; if (pTemplate != NULL)
{
ASSERT_VALID(pTemplate);
_AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault);
}
else
{
// do for all doc template
POSITION pos = m_templateList.GetHeadPosition();
BOOL bFirst = TRUE;
while (pos != NULL)
{
CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
_AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate,
bFirst ? &strDefault : NULL);
bFirst = FALSE;
}
}
// append the "*.*" all files filter
CString allFilter;
VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
strFilter += allFilter;
strFilter += (TCHAR)''\0''; // next string please
strFilter += _T("*.*");
strFilter += (TCHAR)''\0''; // last string
dlgFile.m_ofn.nMaxCustFilter++;
file://Filter文件加在这里!哈哈
dlgFile.m_ofn.lpstrFilter = "图象文件\0*.bmp;*.jpg\0所有文件\0*.*\0\0\0";
dlgFile.m_ofn.lpstrTitle = title;
dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);
int nResult = dlgFile.DoModal();
fileName.ReleaseBuffer();
// modified 5-15-00 PD: delete dialog
delete pDlg;
return nResult == IDOK;
}
好啦,够用了吧,很简单了。