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. Help on obtaining a pointer to my CDocument derived class

Help on obtaining a pointer to my CDocument derived class

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
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.
  • V Offline
    V Offline
    VanHlebar
    wrote on last edited by
    #1

    I need help obtaining a pointer to my CDocument class in a class that I have derived from CTabPageSSL. The TabPageSSL control can be found on this site and it essentially allows you to used child dialog box resources as a TabPage. My problem is this. I need to be able to take text entered on one tab and place it onto a diffent tab. My view class is CFormView which I have then placed a tab control on the main view. On this control is where I have placed two tabs using the TabCtrlSSL. I can respond to the ON_EN_CHANGE of the individual tabs but I can not figure out how to pass this information on to the CDocument class. In all the examples that I have read and seen, they use a function called GetDocument() but this is only available inside my View class. I have attempted to create a function similar to it inside my derived class for my tab pages, but have had no luck. Can anyone help me obtain a pointer to my CDocument or is there an easier way to pass information from between my child dialog boxes? Thanks in advance for any help you can provide. -Eric

    J 1 Reply Last reply
    0
    • V VanHlebar

      I need help obtaining a pointer to my CDocument class in a class that I have derived from CTabPageSSL. The TabPageSSL control can be found on this site and it essentially allows you to used child dialog box resources as a TabPage. My problem is this. I need to be able to take text entered on one tab and place it onto a diffent tab. My view class is CFormView which I have then placed a tab control on the main view. On this control is where I have placed two tabs using the TabCtrlSSL. I can respond to the ON_EN_CHANGE of the individual tabs but I can not figure out how to pass this information on to the CDocument class. In all the examples that I have read and seen, they use a function called GetDocument() but this is only available inside my View class. I have attempted to create a function similar to it inside my derived class for my tab pages, but have had no luck. Can anyone help me obtain a pointer to my CDocument or is there an easier way to pass information from between my child dialog boxes? Thanks in advance for any help you can provide. -Eric

      J Offline
      J Offline
      Jens Kreiensiek
      wrote on last edited by
      #2

      you can use the following function to get your document from any place in your app (just replace 'CMyDocument')...

      CMyDocument* DangerousGetDocument()
      {
      CWinApp* pApp = ::AfxGetApp();
      POSITION p = pApp->GetFirstDocTemplatePosition();
      ASSERT(p);

      CDocTemplate* pTmp = pApp->GetNextDocTemplate(p);
      p = pTmp->GetFirstDocPosition();
      ASSERT(p);

      CDocument* pDoc = pTmp->GetNextDoc(p);
      ASSERT(pDoc);

      return reinterpret_cast<CMyDocument*>(pDoc);
      }

      ..have fun... jk :cool:

      V 1 Reply Last reply
      0
      • J Jens Kreiensiek

        you can use the following function to get your document from any place in your app (just replace 'CMyDocument')...

        CMyDocument* DangerousGetDocument()
        {
        CWinApp* pApp = ::AfxGetApp();
        POSITION p = pApp->GetFirstDocTemplatePosition();
        ASSERT(p);

        CDocTemplate* pTmp = pApp->GetNextDocTemplate(p);
        p = pTmp->GetFirstDocPosition();
        ASSERT(p);

        CDocument* pDoc = pTmp->GetNextDoc(p);
        ASSERT(pDoc);

        return reinterpret_cast<CMyDocument*>(pDoc);
        }

        ..have fun... jk :cool:

        V Offline
        V Offline
        VanHlebar
        wrote on last edited by
        #3

        jk, Thanks for the help. I stumbled onto what appears to be an answer late last night. I am attempting the following... CFrameWnd *pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CFormView *pView = (CFormView *)pFrame->GetActiveView(); CMyDocument *pDoc = (CMyDocument *)pView->GetDocument(); Thanks again though for the help, -Eric

        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