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. Accessing a CTypedPtrArray obj. from a child dialog?

Accessing a CTypedPtrArray obj. from a child dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
4 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.
  • M Offline
    M Offline
    Miguel Lopes
    wrote on last edited by
    #1

    Hi. Im having a rather stupid problem: I have a Cwnd class that has a CTypedPtrArray variable. On a handler, i want to create a Modal dialog and intialize it with some values from the CTypedPtrArray variable in the parent. After i get a valid address to the parent, i can access any variable. My problem is when i try to access the objects in the CTypedPtrArray. The address from "m_array.GetAt(i)" returns ok but the class public variables have bad pointers. Even during normal dialog execution, i cant access it, although i can access all other parent's variable, including a normal pointer to an object of the same class of the CTypedPtrArray array. Any suggestion? thanks in advance Miguel Lopes

    J 1 Reply Last reply
    0
    • M Miguel Lopes

      Hi. Im having a rather stupid problem: I have a Cwnd class that has a CTypedPtrArray variable. On a handler, i want to create a Modal dialog and intialize it with some values from the CTypedPtrArray variable in the parent. After i get a valid address to the parent, i can access any variable. My problem is when i try to access the objects in the CTypedPtrArray. The address from "m_array.GetAt(i)" returns ok but the class public variables have bad pointers. Even during normal dialog execution, i cant access it, although i can access all other parent's variable, including a normal pointer to an object of the same class of the CTypedPtrArray array. Any suggestion? thanks in advance Miguel Lopes

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      How exactly are you getting a pointer to the parent? Is there any multithreading involved? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      M 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        How exactly are you getting a pointer to the parent? Is there any multithreading involved? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        M Offline
        M Offline
        Miguel Lopes
        wrote on last edited by
        #3

        There is no multithreading, at least for now. Im creating it like this: CMyParent* wnd=(CMyParent *)this->GetParent(); int size=wnd->m_array.GetCount(); //<----this works well CString str=wnd->m_array[i]->m_inner_variable; //<--bad ptr, and its valid outside it! ///////////////////////////////////////////////// ANOTHER EXAMPLE i have an array of CMyObject; i created in the dialog a class member CMyObject* obj; then, when i create in the parent window CMyDialog dlg; dlg.obj=m_array.GetAt(i); then when i access "obj" from the OnInitDialog funtion, it works fine!!! The problem is that by this way, i cant add it dinamically, except if i duplicate the whole array.

        M 1 Reply Last reply
        0
        • M Miguel Lopes

          There is no multithreading, at least for now. Im creating it like this: CMyParent* wnd=(CMyParent *)this->GetParent(); int size=wnd->m_array.GetCount(); //<----this works well CString str=wnd->m_array[i]->m_inner_variable; //<--bad ptr, and its valid outside it! ///////////////////////////////////////////////// ANOTHER EXAMPLE i have an array of CMyObject; i created in the dialog a class member CMyObject* obj; then, when i create in the parent window CMyDialog dlg; dlg.obj=m_array.GetAt(i); then when i access "obj" from the OnInitDialog funtion, it works fine!!! The problem is that by this way, i cant add it dinamically, except if i duplicate the whole array.

          M Offline
          M Offline
          Miguel Lopes
          wrote on last edited by
          #4

          Hello? HELP!!! Im getting despered!! X| X| X|

          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