-
modal dlg
How can I make the edit box text of the main dlgbox = that of the modal dlg. That is, a project contains two dlg boxes, dlg1 and dlg2. One has an edit1 and the other edit2. How can I write code for a button in dlg1 so that the value of edit1 because whtever we have in edit2.
I know how to create the project interface, but I just need that one line of code.
-
Hi,
Look at
Code:
int GetWindowText(
HWND hWnd, // handle to window or control
LPTSTR lpString, // text buffer
int nMaxCount // maximum number of characters to copy
);
WM_GETTEXT
WM_GETTEXTLENGTH
-
How really depends on exactly what you're trying to do. If you want to update dlg1 when dlg2 is dismissed (OnOK) then:
Create a CString member variable for edit1 in dlg1, say szText1
Create a CString member variable for edit2 in dlg2, say szText2
if (dlg2.DoModal() == IDOK)
{
szText1 = dlg2.szText2;
UpdateData();
}
If you want to update dlg1 as the text changes, i.e. reflect the keys that the user is typing, you'll need to pass a reference to dlg1 to dlg2 and update dlg1.edit1 in response to EN_CHANGE (I believe) notifications from edit 2
-
szText1 = dlg2.szText2;
does not work. They say 'operator =' function is unavailable
-
sorry
i found the error, instead of CString i had CButton, by mistake.
Thanks