protected: CButton m_Check[5]; CEdit m_Edit[5];void CControlArrayDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CControlArrayDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP for ( int i = 0; i < 5; i++ ) { DDX_Control(pDX, IDC_EDIT1 + i, m_Edit[i]); DDX_Control(pDX, IDC_CHECK1 + i, m_Check[i]); }}void CControlArrayDlg::OnButton1() { for ( int i = 0; i < 5; i++ ) { SetDlgItemText(m_Edit[i].GetDlgCtrlID(), TEXT("XXXXX")); m_Check[i].SetCheck(1); } }
至于你说什么批量操作,就只有你自己知道要什么样的批量操作了。
利用ID创建和使用
CButton *mybutton;
mybutton=(CButton *)GetDlgItem(i);
CButton m_Check[5];
CEdit m_Edit[5];void CControlArrayDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CControlArrayDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
for ( int i = 0; i < 5; i++ )
{
DDX_Control(pDX, IDC_EDIT1 + i, m_Edit[i]);
DDX_Control(pDX, IDC_CHECK1 + i, m_Check[i]);
}}void CControlArrayDlg::OnButton1()
{ for ( int i = 0; i < 5; i++ )
{
SetDlgItemText(m_Edit[i].GetDlgCtrlID(), TEXT("XXXXX"));
m_Check[i].SetCheck(1);
}
}