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. Using CDoc variable in MainFrm

Using CDoc variable in MainFrm

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 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.
  • J Offline
    J Offline
    jw81
    wrote on last edited by
    #1

    Hi I have trouble using CDoc variable in MainFrm. I have included Cdoc.h in MainFrm but the error of undeclared variable still existed.

    CDoc& pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    This is how I normally getting CDoc variable from CView but it doesnt work in MainFrm. Please advise. THanks.

    R 1 Reply Last reply
    0
    • J jw81

      Hi I have trouble using CDoc variable in MainFrm. I have included Cdoc.h in MainFrm but the error of undeclared variable still existed.

      CDoc& pDoc = GetDocument();
      ASSERT_VALID(pDoc);

      This is how I normally getting CDoc variable from CView but it doesnt work in MainFrm. Please advise. THanks.

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      I think there is a GetActiveDocument(). If not that, then use GetActiveFrame(), from there you get the view of the frame and from that the document of the view. Its a bit long winded. If you vote me down, my score will only get lower

      J 2 Replies Last reply
      0
      • R Roger Allen

        I think there is a GetActiveDocument(). If not that, then use GetActiveFrame(), from there you get the view of the frame and from that the document of the view. Its a bit long winded. If you vote me down, my score will only get lower

        J Offline
        J Offline
        jw81
        wrote on last edited by
        #3

        Hi Both of them cannot solve my problem. I got error C2440 for both of them. THanks

        1 Reply Last reply
        0
        • R Roger Allen

          I think there is a GetActiveDocument(). If not that, then use GetActiveFrame(), from there you get the view of the frame and from that the document of the view. Its a bit long winded. If you vote me down, my score will only get lower

          J Offline
          J Offline
          jw81
          wrote on last edited by
          #4

          Hi Thanks for the advice. Now, I created a new dialog class and i wanna use CDoc variable. AfxGetMainWnd doesnt work. I have tried GetActiveDocument and GetActiveFrame but it is for MainFrm. THanks.

          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