Storing string in CStatic
- by Shark
I have to create dynamically allocated array of CStatic (CStatic* array;), which then displayed on the dialog. It must be allocated and filled like this:
array = new CStatic[list_box.GetCount()];
for (int i = 0; i < list_box.GetCount(); i++) {
CString str;
list_box.GetText(i, str);
array[i].Create(str, WS_CHILD, CRect(), GetParent());
}
But str is destroyed after the dialog is closed, because list_box destroyes too, and all pointers inside CStatics points nowhere (I assume it is not working because of this). What can I do to fix this? Any help would be appreciated.
P.S. I know, that this is awful way and this is all wrong and I know how to do this right, but unfortunately, I can't change tasks, they give us in the university :)