Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CArchive and CompoundFile

CArchive and CompoundFile

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wangyiming
    wrote on last edited by
    #1

    the Document is a CompoundFile ( include: ole, image file, ... ) ----------------------------------------------------------- I can open or save Document( 1: CMyDoc::Serialize) but how can I load file to CMfSet Directly ( 2: CMfSet::Open ) 1. ----------------------------------------- void CMyDoc::Serialize(CArchive& ar) { // m_curMfSet is member var of CMyDoc : ( CMfSet m_curMfSet; ) m_curMfSet.Serialize(ar); COleDocument::Serialize(ar); ... }; 2. ----------------------------------------- class CMfSet : public CObject { DECLARE_SERIAL(CMfSet) public: // consturct or disconturct CMfSet(); ~CMfSet(); public: BOOL Open(LPCTSTR lpszFilename); // ... }; BOOL CMfSet::Open(LPCTSTR lpszFilename) { CFile f; if( !f.Open( lpszFilename, CFile::modeRead) ) return FALSE; TRY { char buf[4096]; CArchive ar(&f, CArchive::load, 4096, buf); Serialize(ar); // It is sure error, but I don't know how correct it } CATCH_ALL(e) { return FALSE; } END_CATCH_ALL return TRUE; }; Thank you!

    W 1 Reply Last reply
    0
    • W wangyiming

      the Document is a CompoundFile ( include: ole, image file, ... ) ----------------------------------------------------------- I can open or save Document( 1: CMyDoc::Serialize) but how can I load file to CMfSet Directly ( 2: CMfSet::Open ) 1. ----------------------------------------- void CMyDoc::Serialize(CArchive& ar) { // m_curMfSet is member var of CMyDoc : ( CMfSet m_curMfSet; ) m_curMfSet.Serialize(ar); COleDocument::Serialize(ar); ... }; 2. ----------------------------------------- class CMfSet : public CObject { DECLARE_SERIAL(CMfSet) public: // consturct or disconturct CMfSet(); ~CMfSet(); public: BOOL Open(LPCTSTR lpszFilename); // ... }; BOOL CMfSet::Open(LPCTSTR lpszFilename) { CFile f; if( !f.Open( lpszFilename, CFile::modeRead) ) return FALSE; TRY { char buf[4096]; CArchive ar(&f, CArchive::load, 4096, buf); Serialize(ar); // It is sure error, but I don't know how correct it } CATCH_ALL(e) { return FALSE; } END_CATCH_ALL return TRUE; }; Thank you!

      W Offline
      W Offline
      wangyiming
      wrote on last edited by
      #2

      I had solved it: CRuntimeClass *pRuntimeClass = RUNTIME_CLASS(CMyDoc); CMyDoc *pDoc = (CMyDoc *)(pRuntimeClass->CreateObject()); if( pDoc->OpenDocument(lpszFilename) ) pSet->FromOther( pDoc->GetMfSet() ); delete pDoc; ... ------------------------------------------------------ any advance soultion?( if you have time, please tell me the answer) Thank you!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups