如何从MRU列表mfc获取项目名称? [英] How to get project name from MRU list mfc?
本文介绍了如何从MRU列表mfc获取项目名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我想从MRU列表中获取项目名称。我可以使用这种方法获得最近项目的路径
Hello
I would like to get project names from MRU list. I can get the path of recent project using this method
CString CClipProjectPlanningApp::GetRecentFile(int index)
{
return (*m_pRecentFileList)[index];
}
但我想只有项目名称。
我尝试过:
我知道方法
but I would like to have project names only.
What I have tried:
I know about the method
CRecentFileList::GetDisplayName
但不确切知道如何使用它
我的意思是我不知道如何获得这两个参数
but do not know exactly how to use it
I mean I do not know how to get these 2 parameters
LPCTSTR lpszCurDir,
int nCurDir,
virtual BOOL GetDisplayName(
CString& strName,
int nIndex,
LPCTSTR lpszCurDir,
int nCurDir,
BOOL bAtLeastName = TRUE
) const;
推荐答案
请参阅文档: CRecentFileList类 [ ^ ]。
CRecentFileList
类只管理文件名和注册表中的存储。GetDisplayName()
是一个辅助函数,用于创建要在菜单中显示的名称。
如果项目名称是与普通文件名相同,从完整路径中提取:
See the documentation: CRecentFileList Class[^].
TheCRecentFileList
class just manages file names and the storage in the registry.GetDisplayName()
is a helper function to create names to be show in menus.
If the project name is identical with the plain file name, extract that from the full path:
CString strName(strPath);
int nFileNamePos = strName.ReverseFind(_T('\\'));
if (nFileNamePos >= 0)
{
strName = strName.Mid(nFileNamePos + 1);
int nExtPos = strName.ReverseFind(_T('.'));
if (nExtPos >= 0)
strName = strName.Left(nExtPos);
}
您也可以使用其他功能,例如 _splitpath
和 PathFindFileName
。
如果项目名称存储在您的申请文件中,您必须从列表的每个文件中读取它。
You might also use other functions like _splitpath
and PathFindFileName
.
If the project name is stored in your application documents, you have to read it from each file of the list.
这篇关于如何从MRU列表mfc获取项目名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文