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. Returning from Dialogbox

Returning from Dialogbox

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonquestion
3 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.
  • S Offline
    S Offline
    Sprudling
    wrote on last edited by
    #1

    I've created a modal dialogbox using DialogBox(). The dialog has 2 editboxes and I want the text they contain to somehow be returned to the parent, so I can use them. I thought of using the returnvalue of DialogBox(), which is what I specify when I call EndDialog() from within the dialogbox procedure, and let it point so some structure with 2 strings. But is this the correct approach? I also do not want to use global variables. Any good ideas? Sprudling ;) PS! I'm not using MFC; just plain Win32 API stuff...

    M S 2 Replies Last reply
    0
    • S Sprudling

      I've created a modal dialogbox using DialogBox(). The dialog has 2 editboxes and I want the text they contain to somehow be returned to the parent, so I can use them. I thought of using the returnvalue of DialogBox(), which is what I specify when I call EndDialog() from within the dialogbox procedure, and let it point so some structure with 2 strings. But is this the correct approach? I also do not want to use global variables. Any good ideas? Sprudling ;) PS! I'm not using MFC; just plain Win32 API stuff...

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      1. Make a struct that holds the data (pointers, std::strings, whatever you're using) 2. Use DialogBoxParam() and pass a pointer to that struct as the dwInitParam parameter. 3. In your dialog's window proc, the lParam sent with WM_INITDIALOG is that pointer. Save it with SetWindowLong(hwndDlg, DWL_USER, lParam); 4. Whenever you need to access that pointer again, use GetWindowLong(). --Mike-- #include "witty-sig.h" My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan.

      1 Reply Last reply
      0
      • S Sprudling

        I've created a modal dialogbox using DialogBox(). The dialog has 2 editboxes and I want the text they contain to somehow be returned to the parent, so I can use them. I thought of using the returnvalue of DialogBox(), which is what I specify when I call EndDialog() from within the dialogbox procedure, and let it point so some structure with 2 strings. But is this the correct approach? I also do not want to use global variables. Any good ideas? Sprudling ;) PS! I'm not using MFC; just plain Win32 API stuff...

        S Offline
        S Offline
        solex
        wrote on last edited by
        #3

        Just add 2 strings to your dialog box class. Either make them public or write accessor functions. After DoModal returns your dialog object is still valid and you get the values via dlg.GetValue1(), dlg.GetValue2(). A vast majority of our imports comes from outside the country. George W. Bush

        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