在vc中如何实现下面功能:
比如一个计算器程序,其上有一二十来个button ,假设id 为button1,button2,......
这里它的值并不一定是连续的,现在我希望通过"button"和一个int整数组合成一个button的id ,可以通过什么方法实现呢?我记得原来见过用宏写的,但找不到了。
比如一个计算器程序,其上有一二十来个button ,假设id 为button1,button2,......
这里它的值并不一定是连续的,现在我希望通过"button"和一个int整数组合成一个button的id ,可以通过什么方法实现呢?我记得原来见过用宏写的,但找不到了。
m_button[0].GetsubclassCtrlID( this, IDC_BUTTON0 );是不是这个意思?
m_edit[ 0 ].SubclassDlgItem( IDC_EDIT1, this );
m_edit[ 1 ].SubclassDlgItem( IDC_EDIT2, this );
m_edit[ 2 ].SubclassDlgItem( IDC_EDIT3, this );
m_lbl[ 0 ].SubclassDlgItem( IDC_STATIC1, this );
m_lbl[ 1 ].SubclassDlgItem( IDC_STATIC2, this );
m_lbl[ 2 ].SubclassDlgItem( IDC_STATIC3, this );
for(int i=0;i+=3;i<19)
{
... get the IDC_BUTTONi //就是要简化这里的做法,根据i取得IDC_BUTTONi
pButton->SetWindowText(strInfo);
}
SetWindowText(GetDlgItem(hWnd, COMBINE(IDC_BUTTON, i)), strInfo);
str1 = "BUTTON";
str2.Format(_T("%d"),id);
str1 += str2;
str1中就是你索要的
learn and attention and up
SetWindowText(GetDlgItem(hWnd, COMBINE(IDC_BUTTON, 3)), strInfo);
SetWindowText(GetDlgItem(hWnd, COMBINE(IDC_BUTTON, 4)), strInfo);
这样的都完全正确,但i不是为常量是编译就有问题了,它会认为IDC_BUTTONi没有定义?你认为呢?