首页 > 解决方案 > 是否可以将图像列表保存到文件中?

问题描述

我想知道是否可以创建一个 CImageList 对象并将其保存为文件,以便我可以在其他项目中使用它,如果可以,我该如何保存它?

谢谢。

标签: c++mfcimagelist

解决方案


操作图像列表中所述:

您可以通过调用Write成员函数将图像信息写入存档,并通过调用Read成员函数将其读回。

CArchive可以由任何流支持,包括文件流。CImageList::Write的文档提供了有关如何将图像列表序列化到磁盘的完整示例代码:

// Open the archive to store the image list in.
CFile myFile(_T("myfile.data"), CFile::modeCreate | CFile::modeWrite);
CArchive ar(&myFile, CArchive::store);

// Store the image list in the archive.
m_myImageList.Write(&ar);

推荐阅读