我做的一个编辑器,可以编辑字体和颜色功能,可是当我执行保存功能的时候并不能保存我的操作,就是重新打开的时候并没有保存我之前所做的操作,我设置的基类是CEditView

解决方案 »

  1.   

    void CEditorDoc::Serialize(CArchive& ar)
    {
    // CEditView contains an edit control which handles all serialization
    if(ar.IsStoring())
    {
    ar<<m_fontEdit;
        ar<<m_TextColor;
    }
    else
    {
    ar>>m_fontEdit;
    ar>>m_TextColor;
    }
    ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
    }
    这个保存代码为什么不可以?
    m_fontEdit和m_TextColor是在视图类头文件的成员变量
    我想把改变的设置保存,所以用了序列化函数
      

  2.   

    你的m_fontEdit和m_TextColor是View类里的成员变量,而你的CEditorDoc::Serialize(CArchive& ar) 是Doc类的,怎么直接调用?
    你可以先在View类中复写一个Serialize,然后从Doc中调用View类中的Serialize,在View类中将数据写入磁盘。
      

  3.   

    CFileDialog 文件打开对话框 扩展文件名的问题
    CFileDialog dialog(true,"swf",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
    "flash文件(*.swf)|*.swf|所有文件(*.*)|*.*||",this);
    看孙鑫老师这部分的“|”是用的“\0”1不知道有什么区别?从源头上讲一下|或\0存在的意义
    2我在试验的时候用\0的方法 显示不出文件,为什么?
      

  4.   

    不太懂这个玩意,不过一般数据保存不是通过写ini文件来实现的吗?
      

  5.   

    我已经复写了view类中的serialize函数,但是怎么实现doc类中调用view类呢而且我那个运行有错误。
    Compiling...
    EditorView.cpp
    F:\Editor\EditorView.cpp(124) : warning C4551: function call missing argument list
    F:\Editor\EditorView.cpp(199) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class CArchive' (or there is no acceptable conversion)
    F:\Editor\EditorView.cpp(204) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class CFont' (or there is no acceptable conversion)