Hello, if I understand correctly, you are trying to create a dynamic number of label controls.
I currently do not have the source to the CStaticEx class but I can help you through.
First, put an array class in your header file, I recommend CPtrArray or CPtrList.
CPtrArray m_StaticArray;
Then you will have to add a new and a call to Create() before adding your CStaticEx(s).
int nXaxis,nYaxis;
nXaxis = 0;
nYaxis = 0;
for(int i=0; i < nNumOfCamAttch; i++){
CRect rect(nXaxis + X_PADDING, nYaxis + Y_PADDING , nXaxis + WIDTH + X_PADDING , HEIGHT + Y_PADDING);
nXaxis = X_PADDING + WIDTH + nXaxis ;
CStaticEx* pStaticCtrl = new CStaticEx;
pStaticCtrl->Create(_T("Text"), WS_CHILD|WS_VISIBLE, rect, this, nID);
m_StaticArray.Add(pStaticCtrl);
}
Then, remember to clean it up. In your OnDestroy() handler:
while(m_StaticArray.GetSize() > 0)
{
CStaticEx* pCtrl = (CStaticEx*)m_StaticArray.GetAt(0);
m_StaticArray.RemoveAt(0);
pCtrl->DestroyWindow();
delete pCtrl;
}
I hope this helps, if I got your goal wrong please let me know and I will help.