[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

CStatic Control Array

Posted on 2001-07-12
4
Medium Priority
?
563 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:alexzen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6278880
In general, the technique is OK. You might however want to take a look into 'CArray' to handle that, e.g.

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.
0
 

Author Comment

by:alexzen
ID: 6278993
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.
0
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 6279022
0
 

Author Comment

by:alexzen
ID: 6279161
Thanks, jkr.
I guess I gotta go from here, ain't I?.. so.. here is your point and thank you again, jkr.

Happy programming.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question