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. Communication between TreeView and FormView

Communication between TreeView and FormView

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structuresdebugginghelp
6 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.
  • M Offline
    M Offline
    Maxim Zarus
    wrote on last edited by
    #1

    In my SDI application, I have two views, Treeview and FormView. I placed Edit control on FormView. I have to change value of Edit control by clicking on Tree. Both are different classes. But I am unable to access FormView Class members from Treeview. How can I do that?

    void CLeftView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult)
    {
    //some code
    CRightView *rView = new CRightView();
    if(rView!=NULL)
    {
    rView->m_Edit1.SetWindowText(_T("ok"));
    }
    }

    Code gives Debug Assertion Error.

    P S 2 Replies Last reply
    0
    • M Maxim Zarus

      In my SDI application, I have two views, Treeview and FormView. I placed Edit control on FormView. I have to change value of Edit control by clicking on Tree. Both are different classes. But I am unable to access FormView Class members from Treeview. How can I do that?

      void CLeftView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult)
      {
      //some code
      CRightView *rView = new CRightView();
      if(rView!=NULL)
      {
      rView->m_Edit1.SetWindowText(_T("ok"));
      }
      }

      Code gives Debug Assertion Error.

      P Offline
      P Offline
      Paresh Chitte
      wrote on last edited by
      #2

      Will CDocument::UpdateAllViews will help you ? http://msdn.microsoft.com/en-us/library/eys41xfw(VS.80).aspx[^] Also look at the example given below, http://msdn.microsoft.com/en-us/library/ysfkkk2h(VS.80).aspx[^] Regards, Paresh.

      1 Reply Last reply
      0
      • M Maxim Zarus

        In my SDI application, I have two views, Treeview and FormView. I placed Edit control on FormView. I have to change value of Edit control by clicking on Tree. Both are different classes. But I am unable to access FormView Class members from Treeview. How can I do that?

        void CLeftView::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult)
        {
        //some code
        CRightView *rView = new CRightView();
        if(rView!=NULL)
        {
        rView->m_Edit1.SetWindowText(_T("ok"));
        }
        }

        Code gives Debug Assertion Error.

        S Offline
        S Offline
        sudhir_Kumar
        wrote on last edited by
        #3

        You are creating new View object CRightView *rView = new CRightView();.Instead of this you should get the the attached View object.

        -@SuDhIrKuMaR@-

        M 1 Reply Last reply
        0
        • S sudhir_Kumar

          You are creating new View object CRightView *rView = new CRightView();.Instead of this you should get the the attached View object.

          -@SuDhIrKuMaR@-

          M Offline
          M Offline
          Maxim Zarus
          wrote on last edited by
          #4

          Sir, I am very confused. Please give me some example. How do I create attached view object?

          S 1 Reply Last reply
          0
          • M Maxim Zarus

            Sir, I am very confused. Please give me some example. How do I create attached view object?

            S Offline
            S Offline
            sudhir_Kumar
            wrote on last edited by
            #5

            Try to run this code. CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CView* pFrmView = pFrame->GetActiveView (); CRightView *rView = NULL; if (pFrmView->IsKindOf (RUNTIME_CLASS (CRightView))) rView = (CRightView *)pFrmView; (Your Doc Class Name) * pDoc = GetDocument() if(rView == NULL) { POSITION pos = pDoc->GetFirstViewPosition(); while (pos) { CView* pView = GetNextView (pos); if (pView->IsKindOf (RUNTIME_CLASS (CFormView))) { rView = (CRightView *)pFrmView; } } } if(rView!=NULL) { rView->m_Edit1.SetWindowText(_T("ok")); }

            -@SuDhIrKuMaR@-

            M 1 Reply Last reply
            0
            • S sudhir_Kumar

              Try to run this code. CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CView* pFrmView = pFrame->GetActiveView (); CRightView *rView = NULL; if (pFrmView->IsKindOf (RUNTIME_CLASS (CRightView))) rView = (CRightView *)pFrmView; (Your Doc Class Name) * pDoc = GetDocument() if(rView == NULL) { POSITION pos = pDoc->GetFirstViewPosition(); while (pos) { CView* pView = GetNextView (pos); if (pView->IsKindOf (RUNTIME_CLASS (CFormView))) { rView = (CRightView *)pFrmView; } } } if(rView!=NULL) { rView->m_Edit1.SetWindowText(_T("ok")); }

              -@SuDhIrKuMaR@-

              M Offline
              M Offline
              Maxim Zarus
              wrote on last edited by
              #6

              Now, i get this error: Unhandled exception at 0x00530a33 in MyPrg.exe: 0xC0000005: Access violation reading location 0x1271e40a. and control goes to:

              void CWnd::SetWindowText(LPCTSTR lpszString)
              {
              ENSURE(this);
              ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));

              if (m\_pCtrlSite == NULL)
              	::SetWindowText(m\_hWnd, lpszString);
              else
              	**m\_pCtrlSite->SetWindowText(lpszString);// control points here**
              

              }

              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