As was mentioned, your question is not clear. I work with MFC a lot and, if I understand you, this is an easy thing to do. First, I almost always make control objects where I declare the objects as members of the dialog class and then make a
DDX_CONTROL
entry for each one in the dialog's
DoDataExchange
method. If you have a lot of them then you can make an array of the
CEdit
controls. Here's an example :
class CMyDialog : public CDialog
{
public:
static const int FirstEdit = IDC_FIRST_EDIT_ID;
static const int EditCount = 6;
CEdit m_EditControls[ EditCount ];
public:
void UpdateEditControls();
};
void CMyDialog::DoDataExchange( CDataExchange* pDX )
{
__super::DoDataExchange( pDX );
for( int n = 0; n < EditCount; ++n )
DDX_Control( pDX, FirstEdit + n, m_EditControls[ n ] );
}
void CMyDialog::UpdateEditControls()
{
for( int n = 0; n < EditCount; ++n )
m_EditControls[ n ].SetWindowText( m_EditValueString[ n ] );
}
The last method there, UpdateEditControls, is used to update the text in each of the edit controls. If those values are held in integers then that code needs to be revised accordingly.
Note that this requires the identifiers of each control to be consecutive values or it will not work correctly. Those are usually in the file Resource.h which is a just a text file so you can set them to be what ever you want them to be.
Here's a little helper function that can be useful.
void SetDialogInt( CWnd & control, int value )
{
char buffer[ 64 ];
sprintf( buffer, "%d", value );
control.SetWindowText( buffer );
};
If your data values are integers you can call this function to set the text of the corresponding controls. If they are a different data type then you can make a different helper function to handle that type.