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. Pointer/address to CFormView

Pointer/address to CFormView

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 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.
  • D Offline
    D Offline
    DanYELL
    wrote on last edited by
    #1

    Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have: CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; } But *pView is null and I get an error. How can I make *pView attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)

    PJ ArendsP L 2 Replies Last reply
    0
    • D DanYELL

      Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have: CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; } But *pView is null and I get an error. How can I make *pView attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      You could try pView = GetActiveView();


      You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

      Within you lies the power for good; Use it!

      D 1 Reply Last reply
      0
      • D DanYELL

        Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have: CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; } But *pView is null and I get an error. How can I make *pView attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)

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

        Your code:

        CMyFormView *pView = NULL;

        CListCtrl* pmyListCtrl = &pView->m_list_1098;

        will not work. You have set pView to NULL and then tried to use it as a pointer to a list control object. You may need to review the relationship between your classes.

        It's time for a new signature.

        1 Reply Last reply
        0
        • PJ ArendsP PJ Arends

          You could try pView = GetActiveView();


          You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

          D Offline
          D Offline
          DanYELL
          wrote on last edited by
          #4

          The problem is, GetActiveView() returns something other than the CMyFormView which has the listctrl that I want to attain. Even if I try: void CMainFrame::GetListCtrl() { CMyFormView *pView; CListCtrl* pmyListCtrl = NULL; if (pView) { AfxMessageBox("view active"); pmyListCtrl = pView->m_list_ctrl; int total = pmyListCtrl->GetItemCount(); CString s; s.Format("total = %i", total); AfxMessageBox(s); } } it doesnt work. Please any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)

          L 1 Reply Last reply
          0
          • D DanYELL

            The problem is, GetActiveView() returns something other than the CMyFormView which has the listctrl that I want to attain. Even if I try: void CMainFrame::GetListCtrl() { CMyFormView *pView; CListCtrl* pmyListCtrl = NULL; if (pView) { AfxMessageBox("view active"); pmyListCtrl = pView->m_list_ctrl; int total = pmyListCtrl->GetItemCount(); CString s; s.Format("total = %i", total); AfxMessageBox(s); } } it doesnt work. Please any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)

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

            See my other reply; once again you are trying to use pView without initialising it to point to anything. I would suggest some further study in classes and objects.

            It's time for a new signature.

            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