本文整理汇总了C++中CFileDialog::GetStartPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileDialog::GetStartPosition方法的具体用法?C++ CFileDialog::GetStartPosition怎么用?C++ CFileDialog::GetStartPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileDialog
的用法示例。
在下文中一共展示了CFileDialog::GetStartPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFileadd
void CProjectView::OnFileadd()
{
// Start in the project directory
((CProjectDoc*)GetDocument())->SetProject();
_TCHAR* FileBuffer = new _TCHAR[4096];
CFileDialog *pfileDlg = NULL;
if (g_osrel >= 4)
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
else
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
pfileDlg->m_ofn.lpstrFile = FileBuffer;
FileBuffer[0] = EOS; // Note, must do this or W95 flags as error
pfileDlg->m_ofn.nMaxFile = 4096;
if (pfileDlg->DoModal() != IDOK)
{
//_TCHAR errbuf[512];
//wsprintf(errbuf, _T("FileDialog error: %d"), CommDlgExtendedError());
//AfxMessageBox(errbuf);
delete pfileDlg;
return;
}
CListBox* pLB = (CListBox*)GetDlgItem(IDP_FILELIST);
// Loop through all the files to be added. If they are in the project
// directory or below, just put in the relative path.
POSITION pos = pfileDlg->GetStartPosition();
CString dir(m_directory), path, upath;
dir.MakeUpper();
int i, idx;
while (pos != NULL)
{
path = pfileDlg->GetNextPathName(pos);
upath = path;
upath.MakeUpper();
if (dir.Right(1) != _T("\\"))
dir = dir + _T("\\");
i = upath.Find(dir);
if (i >= 0)
path = path.Mid(i+dir.GetLength());
idx = pLB->AddString(path);
update_scroll(pLB, path);
}
delete FileBuffer;
delete pfileDlg;
((CProjectDoc*)GetDocument())->SetProject();
}
示例2: OnLibadd
void CProjectView::OnLibadd()
{
_TCHAR* FileBuffer = new _TCHAR[4096];
CFileDialog *pfileDlg = NULL;
if (g_osrel >= 4)
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
else
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
pfileDlg->m_ofn.lpstrFile = FileBuffer;
FileBuffer[0] = EOS; // Note, must do this or W95 flags as error
pfileDlg->m_ofn.nMaxFile = 4096;
if (pfileDlg->DoModal() != IDOK)
{
delete pfileDlg;
return;
}
CListBox* pLB = (CListBox*)GetDlgItem(IDP_LIBLIST);
POSITION pos = pfileDlg->GetStartPosition();
CString text;
while (pos != NULL)
{
text = pfileDlg->GetNextPathName(pos);
pLB->AddString(text);
update_scroll(pLB, text);
}
delete FileBuffer;
delete pfileDlg;
((CProjectDoc*)GetDocument())->SetProject();
}