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. troubles on exchanging data between dialog

troubles on exchanging data between dialog

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

    hi all... want to exchange a list control data between dialogs, but when I tried it, it failed and I don't know why..can anyone help? //I initialize the 2nd dialog at the 1st dialog class CAddNeighborsDialog* dlg = new CAddNeighborsDialog; int count = 0; /*inserting data to m_listAddNeighbors(CListCtrl data type)in dialog 2 from m_strData(CStringArray data type)*/ while(count*29m_listAddNeighbors.GetItemCount(); dlg->m_listAddNeighbors.InsertItem(nItem,m_strData.GetAt((count*29)+10)); dlg->m_listAddNeighbors.SetItemText(nItem,1,m_strData.GetAt((count*29)+1)); count++; } if(dlg->DoModal() == IDOK) { //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); } } pls help... thx

    K M D 3 Replies Last reply
    0
    • F firebolt77

      hi all... want to exchange a list control data between dialogs, but when I tried it, it failed and I don't know why..can anyone help? //I initialize the 2nd dialog at the 1st dialog class CAddNeighborsDialog* dlg = new CAddNeighborsDialog; int count = 0; /*inserting data to m_listAddNeighbors(CListCtrl data type)in dialog 2 from m_strData(CStringArray data type)*/ while(count*29m_listAddNeighbors.GetItemCount(); dlg->m_listAddNeighbors.InsertItem(nItem,m_strData.GetAt((count*29)+10)); dlg->m_listAddNeighbors.SetItemText(nItem,1,m_strData.GetAt((count*29)+1)); count++; } if(dlg->DoModal() == IDOK) { //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); } } pls help... thx

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      I am not sure about the rest of your code, but... firebolt77 wrote: //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); This is definitely not going to work, because all controls on a dialog die, when DoModal() comes back. Therefore, you are using GetItemText() from a list control that does not exist. You can try this: Keep a list. E.g, CStringArray variable in your dialog, then override OnOK(), and fill this CStringArray with the items etc in OnOK(). Then later, after DoModal(), you can access this list, and it will still contain the data. this is this.

      F 1 Reply Last reply
      0
      • F firebolt77

        hi all... want to exchange a list control data between dialogs, but when I tried it, it failed and I don't know why..can anyone help? //I initialize the 2nd dialog at the 1st dialog class CAddNeighborsDialog* dlg = new CAddNeighborsDialog; int count = 0; /*inserting data to m_listAddNeighbors(CListCtrl data type)in dialog 2 from m_strData(CStringArray data type)*/ while(count*29m_listAddNeighbors.GetItemCount(); dlg->m_listAddNeighbors.InsertItem(nItem,m_strData.GetAt((count*29)+10)); dlg->m_listAddNeighbors.SetItemText(nItem,1,m_strData.GetAt((count*29)+1)); count++; } if(dlg->DoModal() == IDOK) { //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); } } pls help... thx

        M Offline
        M Offline
        Marc Soleda
        wrote on last edited by
        #3

        I imagine that it's because the dialog it's been destroyed after closing it: add a breakpoint into OnDestroy message handler in your dialog's class. It doesn't fail because it still exists but it has no value. You should retrieve the data before it's destroyed but it depends on how/where you have defined the dialogs. Marc Soleda. ... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.

        1 Reply Last reply
        0
        • K khan

          I am not sure about the rest of your code, but... firebolt77 wrote: //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); This is definitely not going to work, because all controls on a dialog die, when DoModal() comes back. Therefore, you are using GetItemText() from a list control that does not exist. You can try this: Keep a list. E.g, CStringArray variable in your dialog, then override OnOK(), and fill this CStringArray with the items etc in OnOK(). Then later, after DoModal(), you can access this list, and it will still contain the data. this is this.

          F Offline
          F Offline
          firebolt77
          wrote on last edited by
          #4

          thx...it works... Thx for the reply...

          1 Reply Last reply
          0
          • F firebolt77

            hi all... want to exchange a list control data between dialogs, but when I tried it, it failed and I don't know why..can anyone help? //I initialize the 2nd dialog at the 1st dialog class CAddNeighborsDialog* dlg = new CAddNeighborsDialog; int count = 0; /*inserting data to m_listAddNeighbors(CListCtrl data type)in dialog 2 from m_strData(CStringArray data type)*/ while(count*29m_listAddNeighbors.GetItemCount(); dlg->m_listAddNeighbors.InsertItem(nItem,m_strData.GetAt((count*29)+10)); dlg->m_listAddNeighbors.SetItemText(nItem,1,m_strData.GetAt((count*29)+1)); count++; } if(dlg->DoModal() == IDOK) { //I try to test it using message box, but the message box shows nothing MessageBox(dlg->m_listAddNeighbor.GetItemText(0,1)); } } pls help... thx

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            firebolt77 wrote: CAddNeighborsDialog* dlg = new CAddNeighborsDialog; Why do this, especially when there is no delete shown? It just ties up the memory manager unnecessarily.


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            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