In my MFC project, I want to generate the labels dynamically. E开发者_如何学JAVAg: I have to generate 4 edit controls and corresponding labels for them- say "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);
}
I want "Label1" "Label2"... etc in place of "Name_of_label" I am not very sure how to go about it.
Thanks in advance,
How about something like this:
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);
}
精彩评论