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. SOLVED: MFC: document-view problem [modified]

SOLVED: MFC: document-view problem [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
3 Posts 2 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.
  • P Offline
    P Offline
    progDes
    wrote on last edited by
    #1

    My application was generared with wizard. It'is SDI. The problem: The document do not automatically attach to the view. The document is creating but the m_pDocument in the view class is always NULL. How can I solve this problem? -- modified at 2:03 Saturday 8th September, 2007

    C 1 Reply Last reply
    0
    • P progDes

      My application was generared with wizard. It'is SDI. The problem: The document do not automatically attach to the view. The document is creating but the m_pDocument in the view class is always NULL. How can I solve this problem? -- modified at 2:03 Saturday 8th September, 2007

      C Offline
      C Offline
      chandu004
      wrote on last edited by
      #2

      thats vary simple. say for example, your sdi application is named as example, then your view will be CexampleView and your document class will be CexampleDoc. now your requirement is to get the object of CexampleDoc in CexampleView right?, if it is so, the following is the logic. in CexampleView class(.h file) define a variable like this. CexampleDoc *pDoc; and in constructor or ondraw, pDoc=GetDocument(); now you can access the document class with pDoc.

      P 1 Reply Last reply
      0
      • C chandu004

        thats vary simple. say for example, your sdi application is named as example, then your view will be CexampleView and your document class will be CexampleDoc. now your requirement is to get the object of CexampleDoc in CexampleView right?, if it is so, the following is the logic. in CexampleView class(.h file) define a variable like this. CexampleDoc *pDoc; and in constructor or ondraw, pDoc=GetDocument(); now you can access the document class with pDoc.

        P Offline
        P Offline
        progDes
        wrote on last edited by
        #3

        Thanks but I know document/view architecture. I found the problem. IMPLEMENT_DYNCREATE(CSalesmanView, CScrollView) BEGIN_MESSAGE_MAP(CSalesmanView, CScrollView) changed to IMPLEMENT_DYNCREATE(CSalesmanView, CFormView) BEGIN_MESSAGE_MAP(CSalesmanView, CFormView) I was changed the parent of CSalesmanView from CScrollView to CFormView by hand and forgot to change this. SOLVED

        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