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. pointer to active document

pointer to active document

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studioquestion
5 Posts 3 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.
  • R Offline
    R Offline
    RalfPeter
    wrote on last edited by
    #1

    Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.

    ralf.riedel@usm.edu

    S M 3 Replies Last reply
    0
    • R RalfPeter

      Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.

      ralf.riedel@usm.edu

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      How many document types are there?

      Steve

      R 1 Reply Last reply
      0
      • S Stephen Hewitt

        How many document types are there?

        Steve

        R Offline
        R Offline
        RalfPeter
        wrote on last edited by
        #3

        One type only

        ralf.riedel@usm.edu

        1 Reply Last reply
        0
        • R RalfPeter

          Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.

          ralf.riedel@usm.edu

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          What is the value of "pDoc" when the crash occurs?

          Steve

          1 Reply Last reply
          0
          • R RalfPeter

            Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.

            ralf.riedel@usm.edu

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            For MDI isn't the active document associated with a view in an MDI child? I'm assuming m_pMainWnd points to a CMDIFrameWnd... CMDIChildWnd *pActiveMDIChild = ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive(); CMDIChildWnd *pActiveMDIChild = ((CMDIFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive(); if (pActiveMDIChild) { CMtxDoc *pDoc = (CMtxDoc *)pActiveMDIChild->GetActiveDocument(); ... } Mark -- modified at 19:25 Tuesday 16th January, 2007

            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