Disconnect data exchange
-
Hi to you all, In a Dialog, I use an Edit element to enter a key value for new objects. I use the same dialog somewhere else to select one of the objects and I then replace this CEdit element with a CComboBox from which the value can be selected. I would likt to use the same CString variable. In the current version, this CString is connected to the CEdit object in the DoDataExchange by a DDX_Text(pDX,.....). I would likt (in the OnInitDialog routine) to disconnect this CString from the CEdit element, and reconnect it (with a new DDX_Text probably) to the CComboBox element. Is there a way in which one can disconnect the data exchange? Or should I take the DDX_Text for this element out of DoDataExchange and put it in OnInitDialog altogether? Anyone have any suggestions? Thanks in advance William
-
Hi to you all, In a Dialog, I use an Edit element to enter a key value for new objects. I use the same dialog somewhere else to select one of the objects and I then replace this CEdit element with a CComboBox from which the value can be selected. I would likt to use the same CString variable. In the current version, this CString is connected to the CEdit object in the DoDataExchange by a DDX_Text(pDX,.....). I would likt (in the OnInitDialog routine) to disconnect this CString from the CEdit element, and reconnect it (with a new DDX_Text probably) to the CComboBox element. Is there a way in which one can disconnect the data exchange? Or should I take the DDX_Text for this element out of DoDataExchange and put it in OnInitDialog altogether? Anyone have any suggestions? Thanks in advance William
Wim Engberts wrote:
...this CString is connected to the CEdit object...
Use a
CEdit
member variable instead. For the combobox control, use aCComboBox
member variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Wim Engberts wrote:
...this CString is connected to the CEdit object...
Use a
CEdit
member variable instead. For the combobox control, use aCComboBox
member variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
David, This is indeed what I do, however, I would like both controls to do their data exchange with the same CString variable, since I always show only one of the two (either the CEdit or the CComboBox), depending on the mode that I have selected for the dialog. I am now experimenting with a double DDX_Text in the DoDataExchange routine (referring both controls to the same CString). This compiles fine and it also seems to work properly. However, when starting the classwizard, I get an error. So far I have been able to go around this by putting the second DDX_Text outside of Microsoft's automatic data map (so putting it behind the "//}}AFX_DATA_MAP" line). So far, this seems to work properly. Regards, William
-
David, This is indeed what I do, however, I would like both controls to do their data exchange with the same CString variable, since I always show only one of the two (either the CEdit or the CComboBox), depending on the mode that I have selected for the dialog. I am now experimenting with a double DDX_Text in the DoDataExchange routine (referring both controls to the same CString). This compiles fine and it also seems to work properly. However, when starting the classwizard, I get an error. So far I have been able to go around this by putting the second DDX_Text outside of Microsoft's automatic data map (so putting it behind the "//}}AFX_DATA_MAP" line). So far, this seems to work properly. Regards, William
While ClassWizard is nice, do not let it ultimately govern how you lay out your code. It's meant to solve a problem a particular way, but that does not mean that other ways can't also be employed.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb