字体怎样串行化?

LoveAlien 2001-12-13 03:39:06
CFont m_tempFont;
字体初始化
在Serialize(CArchive &ar)中我想要对m_tempFont进行串行化
但是,下面的写法不能成功
//存储
ar.Write(&m_tempFont,sizeof(m_tempFont));
//读取
ar.Read(&m_tempFont,sizeof(m_tempFont));
请问,字体怎样才能达到串行化的目的。
...全文
127 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
plusplus 2001-12-13
  • 打赏
  • 举报
回复
for a windows object, you don't know how it's data is organized, and you don't know where it's data.
it has a handle, say, HFONT, but next time when you start your program, the handle will change.
while, however, there internal data is not changed, the internal data is those we care, for example, LOGFONT. or, it's properties.
OK.
LoveAlien 2001-12-13
  • 打赏
  • 举报
回复
Thank you very much!
能不能,将一下原因。
plusplus 2001-12-13
  • 打赏
  • 举报
回复
you must get the logic font. that's LOGFONT,
then, you can serialize the LOGFONT.
CFont is a Windows Object, you can't serialize it.
And CFont::GetLogFont can get the LOGFONT.
LOGFONT lf;
m_tempFont.GetLogFont(&lf);
ar.Write(&lf, sizeof(LOGFONT));
LoveAlien 2001-12-13
  • 打赏
  • 举报
回复
Who Can Help Me?
LoveAlien 2001-12-13
  • 打赏
  • 举报
回复
但是,我现在遇到了这样一个问题,想请大家帮忙解决一下。
guanjinke 2001-12-13
  • 打赏
  • 举报
回复
以我的经验看来,用Serialize,太不自由,还不如直接写文件用CFile类
LoveAlien 2001-12-13
  • 打赏
  • 举报
回复
Help Me!

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧