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 question....

pointer question....

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 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.
  • H Offline
    H Offline
    hearties
    wrote on last edited by
    #1

    How can I change the value of my document data from another class? in my sample MFC code in MyProjectView.cpp: ... ... CMyObject* pPencil = GetDocument()->m_pPencil; // the value of GetDocument()->m_pPencil->Length is 0 pPencil->Length = 2; ... ... somehow when I execute this code, the value of m_pPencil->Length in the document is still 0. how can I change the document data from my project's View class? :(

    S 1 Reply Last reply
    0
    • H hearties

      How can I change the value of my document data from another class? in my sample MFC code in MyProjectView.cpp: ... ... CMyObject* pPencil = GetDocument()->m_pPencil; // the value of GetDocument()->m_pPencil->Length is 0 pPencil->Length = 2; ... ... somehow when I execute this code, the value of m_pPencil->Length in the document is still 0. how can I change the document data from my project's View class? :(

      S Offline
      S Offline
      Stan Shannon
      wrote on last edited by
      #2

      Try this: CMyView:: { GetDocument()->m_pPencil->SetPencilLength( 1 ); } or, even better, as the document should be responsible for managing the data defined within it (as with any well designed object class ) CMyView:: { GetDocument()->SetPencilLength( 1 ); } CMyDocument::SetPencilLength( int length ) { ASSERT( NULL != m_pPencil ); // And other appropriate checks! m_pPencil->SetPencilLength( length ); }

      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