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. Need help with pointer in View

Need help with pointer in View

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
9 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.
  • E Offline
    E Offline
    E3
    wrote on last edited by
    #1

    hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages class CTestView : public CFormView and i have a different class and object some where else and i want to point to this class where i double click my control and load my images CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow(); I new at this MFC Visual C++ program can any one please help me thanks...........

    C K M 3 Replies Last reply
    0
    • E E3

      hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages class CTestView : public CFormView and i have a different class and object some where else and i want to point to this class where i double click my control and load my images CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow(); I new at this MFC Visual C++ program can any one please help me thanks...........

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

      I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

      E 1 Reply Last reply
      0
      • C Christian Graus

        I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

        E Offline
        E Offline
        E3
        wrote on last edited by
        #3

        No that dosen't work :(:((:((:(

        C 1 Reply Last reply
        0
        • E E3

          No that dosen't work :(:((:((:(

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

          CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd(); pMain->GetActiveView(); Sorry, I abandoned MFC a long time ago. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

          E 1 Reply Last reply
          0
          • C Christian Graus

            CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd(); pMain->GetActiveView(); Sorry, I abandoned MFC a long time ago. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

            E Offline
            E Offline
            E3
            wrote on last edited by
            #5

            It's ok thanks for trying :) in my program the is no GetActiveView() i keep getting an error. maybe i'm putting this in the wrong way this is what i have CTestView * pView= (CTestView*)AfxGetMainWnd(); and lets say i want to call and function or an object like this pView->m_cThumbFrame.Add("picture.bmp"); but this dosen't work :(:((:((:((

            C 1 Reply Last reply
            0
            • E E3

              It's ok thanks for trying :) in my program the is no GetActiveView() i keep getting an error. maybe i'm putting this in the wrong way this is what i have CTestView * pView= (CTestView*)AfxGetMainWnd(); and lets say i want to call and function or an object like this pView->m_cThumbFrame.Add("picture.bmp"); but this dosen't work :(:((:((:((

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

              E3 wrote: in my program the is no GetActiveView() i keep getting an error. After the cast ? Compiles fine here. E3 wrote: CTestView * pView= (CTestView*)AfxGetMainWnd(); Won't work. You'll get the CMainFrame class, which when cast has a GetActiveView() method. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002

              1 Reply Last reply
              0
              • E E3

                hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages class CTestView : public CFormView and i have a different class and object some where else and i want to point to this class where i double click my control and load my images CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow(); I new at this MFC Visual C++ program can any one please help me thanks...........

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                It would be better to store the view-pointer for each view in a own variable to ensure you getting the right view pointer. If not you are to crush and not to know why.:~ (If you do´t do this than check with the CObject::IsKindOf or something that the pointer is a object type of the class) Try this @ home. (B&B)

                1 Reply Last reply
                0
                • E E3

                  hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages class CTestView : public CFormView and i have a different class and object some where else and i want to point to this class where i double click my control and load my images CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow(); I new at this MFC Visual C++ program can any one please help me thanks...........

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

                  I find it easier to store a pointer to the CView derived class in my CWinApp derived class. This guarantees that I'm working on the correct view. Assuming you are calling your function from your CFrameWnd derived class, you may be able to use GetActiveView and cast it to the CTestView. I prefer the first method but then I tend to have a lot of CView classes in my projects. Michael Fat bottomed girls You make the rockin' world go round -- Queen

                  E 1 Reply Last reply
                  0
                  • M Michael P Butler

                    I find it easier to store a pointer to the CView derived class in my CWinApp derived class. This guarantees that I'm working on the correct view. Assuming you are calling your function from your CFrameWnd derived class, you may be able to use GetActiveView and cast it to the CTestView. I prefer the first method but then I tend to have a lot of CView classes in my projects. Michael Fat bottomed girls You make the rockin' world go round -- Queen

                    E Offline
                    E Offline
                    E3
                    wrote on last edited by
                    #9

                    thank you all for helping me... I finaly got the some of a b.... to work hehehe here is what i did to get it working for all those people who mite get stuck on this and are new like me. CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd(); CTestView *p = (CTestView *)pFrame->GetActiveView(); p->LoadImages(str); and this get the current CFormView window and everything works..... thanks all guys....for all your help ;);):):):):) E3

                    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