在我的 MFC 项目中,我想动态生成标签。 例如: 我必须为它们生成 4 个编辑控件和相应的标签——比如“Label1”“Label2”......
CStatic *label[MAX_THREAD];
for (int i=0; i< dynamic_number ; i++)
{
label[i] = new CStatic;
label[i]->Create(L"Name_of_label", WS_CHILD | WS_VISIBLE,
CRect(10, (10+i*30), 70, (30+i*30)), this);
}
我想要“Label1”“Label2”...等代替“Name_of_label” 我不太确定该怎么做。
提前致谢
最佳答案
这样的事情怎么样:
CString str;
CStatic *label[MAX_THREAD];
for (int i = 0; i < dynamic_number ; i++)
{
str.Format("Label%d", i);
label[i] = new CStatic;
label[i]->Create(str,
WS_CHILD | WS_VISIBLE,
CRect(10, (10+i*30), 70, (30+i*30)),
this);
}
关于mfc - 动态生成标签- MFC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6588776/