I have this struct definition:
typedef struct tagPublicTalkInfo
{
CString strAwayCong1;
CString strAwayCong2;
CString strAwayBrother1;
CString strAwayBrother2;
CString strChairman;
CString strCong;
CString strHosp;
CString strReader;
CString strBrother;
CString strTheme;
CString strWTConductor;
CString strInterpreter;
CString strMisc;
CString strWatchtowerStudyTheme;
CString strServiceTalkTheme;
CString strBibleVersesReader;
CString strVideoHost;
CString strVideoCohost;
CString strOpeningPrayer;
CString strClosingPrayer;
int iSongStart;
int iSongMiddle;
int iSongEnd;
int iThemeNumber;
} S_TALK_INFO;
This structure is passed into a dialog and retrieved like this:
void CWeekendMeetingDlg::SetWeekendMeetingInfo(S_TALK_INFO &rsTalkInfo)
{
m_sWeekendMeetingInfo = rsTalkInfo;
}
S_TALK_INFO CWeekendMeetingDlg::GetWeekendMeetingInfo()
{
return m_sWeekendMeetingInfo;
}
At the moment I am mapping the dialog controls to distinct variables and transfer to / from my structure. For example:
m_strChairman = m_sWeekendMeetingInfo.strChairman;
m_sWeekendMeetingInfo.strChairman = m_strChairman;
Is possible to map my controls directly to the structure member CString variables or would that be considered bad practice?
Yes, as Adrian says, you don't have to confine yourself to using the variables that the wizard would hand you. I used my test project to do this with the about dialog.
Here I passed a reference to the external data to work on it directly. Because of the
DoDataExchangemechanism, The data will only be modified if the user pushes OK. I added the firstDDX_Texthandler with the wizard, hence the commented valuedummy. I just copied and pasted that handler to add the second.I put the assert in the app command so the program would break there and could examine the data.