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