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. How to get object of a view which is created using AddView().

How to get object of a view which is created using AddView().

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
8 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.
  • S Offline
    S Offline
    Sampath579
    wrote on last edited by
    #1

    Hi In my mfc application i created a window with multiple tabs as follows:

    class MainWind: public CTabView
    {
    void OnCreate(LPCREATESTRUCT lpstruct)
    {
    if (CTabView::OnCreate(lpCreateStruct) == -1)
    return -1;

            AddView(RUNTIME\_CLASS(CView1), \_T("Sheet1"));
      }
    

    }

    class CView1 : public CScrollView
    {
    CView1()
    {

     }
     void LoadData()
     {
    
     }
    

    }

    A window is created with one tab and CView1 is the view class for my window. After AddView() i want to call LoadData() function which is available in CView1 class. May i know how to get the object of CView1 class in my MainWindclass.

    V L 2 Replies Last reply
    0
    • S Sampath579

      Hi In my mfc application i created a window with multiple tabs as follows:

      class MainWind: public CTabView
      {
      void OnCreate(LPCREATESTRUCT lpstruct)
      {
      if (CTabView::OnCreate(lpCreateStruct) == -1)
      return -1;

              AddView(RUNTIME\_CLASS(CView1), \_T("Sheet1"));
        }
      

      }

      class CView1 : public CScrollView
      {
      CView1()
      {

       }
       void LoadData()
       {
      
       }
      

      }

      A window is created with one tab and CView1 is the view class for my window. After AddView() i want to call LoadData() function which is available in CView1 class. May i know how to get the object of CView1 class in my MainWindclass.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Can this discussion [[RESOLVED] MDI CTabView](http://forums.codeguru.com/showthread.php?540827-RESOLVED-MDI-CTabView) help you?

      S 1 Reply Last reply
      0
      • S Sampath579

        Hi In my mfc application i created a window with multiple tabs as follows:

        class MainWind: public CTabView
        {
        void OnCreate(LPCREATESTRUCT lpstruct)
        {
        if (CTabView::OnCreate(lpCreateStruct) == -1)
        return -1;

                AddView(RUNTIME\_CLASS(CView1), \_T("Sheet1"));
          }
        

        }

        class CView1 : public CScrollView
        {
        CView1()
        {

         }
         void LoadData()
         {
        
         }
        

        }

        A window is created with one tab and CView1 is the view class for my window. After AddView() i want to call LoadData() function which is available in CView1 class. May i know how to get the object of CView1 class in my MainWindclass.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You should capture the index value returned by CTabView::AddView[^]

        S 1 Reply Last reply
        0
        • V Victor Nijegorodov

          Can this discussion [[RESOLVED] MDI CTabView](http://forums.codeguru.com/showthread.php?540827-RESOLVED-MDI-CTabView) help you?

          S Offline
          S Offline
          Sampath579
          wrote on last edited by
          #4

          No. I am unable to get that View object. Any other way?

          V 1 Reply Last reply
          0
          • S Sampath579

            No. I am unable to get that View object. Any other way?

            V Offline
            V Offline
            Victor Nijegorodov
            wrote on last edited by
            #5

            Then use the index returned by AddView. :suss:

            1 Reply Last reply
            0
            • L Lost User

              You should capture the index value returned by CTabView::AddView[^]

              S Offline
              S Offline
              Sampath579
              wrote on last edited by
              #6

              I will get the index of view, but how to access that view using index.? I dint find any function like GetView(index) or something similar to it..

              V L 2 Replies Last reply
              0
              • S Sampath579

                I will get the index of view, but how to access that view using index.? I dint find any function like GetView(index) or something similar to it..

                V Offline
                V Offline
                Victor Nijegorodov
                wrote on last edited by
                #7

                Sampath579 wrote:

                I will get the index of view, but how to access that view using index.? I dint find any function like GetView(index) or something similar to it..

                You could try calling CTabView::SetActiveView followed by CTabView::GetActiveView

                1 Reply Last reply
                0
                • S Sampath579

                  I will get the index of view, but how to access that view using index.? I dint find any function like GetView(index) or something similar to it..

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Each call to AddView returns an index of the tab view. So when you want to make a particular view active you just call SetActiveView passing the relevant index value.

                  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