alexzen
asked on
CStatic Control Array
Hi, all.
This may be a dumb question but.. I have bunch of CStatic controls on my form and so far I used member variables such as m_Static1, m_Static2...etc to handle them (changing bitmaps).
Now I need 20 of those CStatic controls doing the same thing, and I think that it's time to have a for loop to take care of the logic and ease the pain of maintenance of the code section. I thought about it with the code at the bottom:
CStatic *pStatic = new CStatic[5];
pStatic[0].m_hWnd = m_Static1.m_hWnd;
pStatic[1].m_hWnd = m_Static2.m_hWnd;
...
for (i=0;i<20;i++) {
pStatic[i]...
}
My question is "Is this a right way to do??"
In VB, we can use "control array" but how we do that in VC++??
Thank you for your time, folks.
This may be a dumb question but.. I have bunch of CStatic controls on my form and so far I used member variables such as m_Static1, m_Static2...etc to handle them (changing bitmaps).
Now I need 20 of those CStatic controls doing the same thing, and I think that it's time to have a for loop to take care of the logic and ease the pain of maintenance of the code section. I thought about it with the code at the bottom:
CStatic *pStatic = new CStatic[5];
pStatic[0].m_hWnd = m_Static1.m_hWnd;
pStatic[1].m_hWnd = m_Static2.m_hWnd;
...
for (i=0;i<20;i++) {
pStatic[i]...
}
My question is "Is this a right way to do??"
In VB, we can use "control array" but how we do that in VC++??
Thank you for your time, folks.
ASKER
Thank you, jkr. I really appreciate it.
Could you please explain more on CArray template or.. could you give me a sample code or link about how to use CArray template?? I heard about it but it's kind of new to me.. so..
Thank you again, jkr.
Could you please explain more on CArray template or.. could you give me a sample code or link about how to use CArray template?? I heard about it but it's kind of new to me.. so..
Thank you again, jkr.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, jkr.
I guess I gotta go from here, ain't I?.. so.. here is your point and thank you again, jkr.
Happy programming.
I guess I gotta go from here, ain't I?.. so.. here is your point and thank you again, jkr.
Happy programming.
CArray<CStatic*,CStatic*> pStatic;
or even
typedef CArray<CStatic*,CStatic*> CStaticPointerArray;
CStaticPointerArray pStatic;
which eases a lot of the pain of handling the data in this container.