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. pointers to doc class from other classes

pointers to doc class from other classes

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutoriallearning
4 Posts 4 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.
  • Q Offline
    Q Offline
    Qbus
    wrote on last edited by
    #1

    Hi, sorry that this might be a beginner question. I know how to get a pointer form View class to doc class. But how do you get a pointer from app class to doc class? is there a way? If not can you get a pointer to app class from doc class? Thanks for your help Q-Bus

    C P M 3 Replies Last reply
    0
    • Q Qbus

      Hi, sorry that this might be a beginner question. I know how to get a pointer form View class to doc class. But how do you get a pointer from app class to doc class? is there a way? If not can you get a pointer to app class from doc class? Thanks for your help Q-Bus

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      from the app, I believe you can call GetActiveView() or something. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • Q Qbus

        Hi, sorry that this might be a beginner question. I know how to get a pointer form View class to doc class. But how do you get a pointer from app class to doc class? is there a way? If not can you get a pointer to app class from doc class? Thanks for your help Q-Bus

        P Offline
        P Offline
        Peter Molnar
        wrote on last edited by
        #3

        Do the following: 1.Add a member variable to your app class

        CYourDoc* m_pYourDoc;

        2.Add a memeber function to your app class:

        SetYourDoc(CYourDoc* pYourDoc)
        {
        m_pYourDoc = pYourDoc;
        }

        3.In your doc class' constructor call

        theApp.SetYourDoc(this);

        Peter Molnar

        1 Reply Last reply
        0
        • Q Qbus

          Hi, sorry that this might be a beginner question. I know how to get a pointer form View class to doc class. But how do you get a pointer from app class to doc class? is there a way? If not can you get a pointer to app class from doc class? Thanks for your help Q-Bus

          M Offline
          M Offline
          Michael P Butler
          wrote on last edited by
          #4

          Qbus wrote: I know how to get a pointer form View class to doc class. If it is a standard MFC Wizard generated view then you can use the GetDocument() function in your view class. Qbus wrote: If not can you get a pointer to app class from doc class? You can use AfxGetApp() and cast the returned value to your class CMyApp* pApp = (CMyApp*) AfxGetApp(); Michael Snow is lying on the ground, and in the air the sleigh bells sound, The frosted patterned window panes, it's British summer time again. No, it's not, It's Christmas - Santa Claus in on the Dole (Spitting Image 1986)

          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