维护最近的文件列表
我想在我的 MFC 应用程序上维护一个简单的最近文件列表,其中显示 4 个最近使用的文件名。
我一直在使用 Eugene Kain 的“The MFC Answer Book”中的一个示例,该示例可以以编程方式将字符串添加到基于标准文档/视图体系结构的应用程序的“最近的文件”列表中:(请参阅“管理最近的文件列表 (MRU)” ) :
http://www.nerdbooks.com/isbn/0201185377
我的应用程序是一个相当轻量级的应用程序不使用文档/视图体系结构来管理数据、文件格式等的实用程序。我不确定上面示例中使用的相同原则是否适用于此。
有谁有任何示例说明如何维护“文件”菜单中显示的最近文件列表,并且可以存储在某处的文件/注册表设置中?最重要的是,我缺乏知识和理解力阻碍了我。
更新:我最近发现这篇 CodeProject 文章非常有用...
I would like to maintain a simple recent files list on my MFC application that shows the 4 most recently used file names.
I have been playing with an example from Eugene Kain's "The MFC Answer Book" that can programmatically add strings to the Recent Files list for an application based on the standard Document/View architecture: (see "Managing the Recent Files List (MRU)") :
http://www.nerdbooks.com/isbn/0201185377
My application is a fairly lightweight utility that does not use the Document/View architecture to manage data, file formats and so on. I am not sure if the same principles used in the above example would be applicable here.
Does anyone have any examples of how they go about maintaining a recent files list that is displayed in the File menu, and can be stored in a file / registry setting somewhere? More than anything, it's my lack of knowledge and understanding that is holding me back.
Update: I have recently found this CodeProject article to be quite useful...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最近使用 MFC 做到了这一点,所以既然您似乎也在使用 MFC,也许它会有所帮助:
in:
//..
//...
您只需要您的应用程序派生自
CWinApp
(我使用从 CFrameWnd 派生的类来处理菜单,也许您也这样做?)。告诉我这是否适合你。不确定我是否拥有一切。
I recently did that using MFC, so since you seems to be using MFC as well maybe it will help:
in:
//..
//...
You only need that your application is derived from
CWinApp
(and I use a class derived fromCFrameWnd
to handle the menu, maybe you do the same?).Tell me if that works for you. Not sure if I have everything.
您可以使用 Boost 循环缓冲区 算法来在程序运行时维护该列表,然后在每次更新时将其保存到注册表(应该是微不足道的),并在程序首次启动时加载它。
You can use the boost circular buffer algorithm to maintain the list while the program is running, and then save it to the registry (should be trivial) every time it's updated, and load it when the program first starts.