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. SOLVED - Passing CObject to OnUpdate - compiler error C2039 [modified]

SOLVED - Passing CObject to OnUpdate - compiler error C2039 [modified]

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

    I am trying to use CObject *pHint in CView OnUpdate. Here is my instantiation of CObject derived class: .... m_C_Parameters = new C_Parameters(); // CObject base class VERIFY(m_C_Parameters); m_C_Parameters->hello = 10; // set test variable m_CCCC_ParserDoc->UpdateAllViews(NULL,RED,m_C_Parameters); .... Variable int hello is declared in C_Parameters(); Here is my OnUpdate override in CView dereived class: void C_List_View_::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { int test = pHint->hello; ....... However, the compiler gets me an error: error C2039: 'hello' : is not a member of 'CObject' f:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject' What did I missed? Thanks for yor help. Vaclav

    modified on Friday, May 16, 2008 1:01 PM

    M K 2 Replies Last reply
    0
    • V Vaclav_

      I am trying to use CObject *pHint in CView OnUpdate. Here is my instantiation of CObject derived class: .... m_C_Parameters = new C_Parameters(); // CObject base class VERIFY(m_C_Parameters); m_C_Parameters->hello = 10; // set test variable m_CCCC_ParserDoc->UpdateAllViews(NULL,RED,m_C_Parameters); .... Variable int hello is declared in C_Parameters(); Here is my OnUpdate override in CView dereived class: void C_List_View_::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { int test = pHint->hello; ....... However, the compiler gets me an error: error C2039: 'hello' : is not a member of 'CObject' f:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject' What did I missed? Thanks for yor help. Vaclav

      modified on Friday, May 16, 2008 1:01 PM

      M Offline
      M Offline
      mid 5741
      wrote on last edited by
      #2

      You need to cast pHint to C_Parameters* before you can call hello on it.

      Henry David Thoreau wrote:

      Beware of all enterprises that require new clothes.

      K 1 Reply Last reply
      0
      • V Vaclav_

        I am trying to use CObject *pHint in CView OnUpdate. Here is my instantiation of CObject derived class: .... m_C_Parameters = new C_Parameters(); // CObject base class VERIFY(m_C_Parameters); m_C_Parameters->hello = 10; // set test variable m_CCCC_ParserDoc->UpdateAllViews(NULL,RED,m_C_Parameters); .... Variable int hello is declared in C_Parameters(); Here is my OnUpdate override in CView dereived class: void C_List_View_::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { int test = pHint->hello; ....... However, the compiler gets me an error: error C2039: 'hello' : is not a member of 'CObject' f:\program files\microsoft visual studio\vc98\mfc\include\afx.h(666) : see declaration of 'CObject' What did I missed? Thanks for yor help. Vaclav

        modified on Friday, May 16, 2008 1:01 PM

        K Offline
        K Offline
        Kelly Herald
        wrote on last edited by
        #3

        You forgot to cast pHint to your derived class.

        C_Parameters *pParameters = (C_Parameters*)pHint;
        int test = pParameters->hello;

        Kelly Herald Software Developer

        V 1 Reply Last reply
        0
        • M mid 5741

          You need to cast pHint to C_Parameters* before you can call hello on it.

          Henry David Thoreau wrote:

          Beware of all enterprises that require new clothes.

          K Offline
          K Offline
          Kelly Herald
          wrote on last edited by
          #4

          Dang, Michael, you beat me to the answer by a minute. :)

          Kelly Herald Software Developer

          1 Reply Last reply
          0
          • K Kelly Herald

            You forgot to cast pHint to your derived class.

            C_Parameters *pParameters = (C_Parameters*)pHint;
            int test = pParameters->hello;

            Kelly Herald Software Developer

            V Offline
            V Offline
            Vaclav_
            wrote on last edited by
            #5

            Thanks a milion! I hope I did not start any feud between both of you! Vaclav

            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