Solved

For looping

Posted on 2002-03-15
2
239 Views
Last Modified: 2010-04-01
Hi,

I would like to set many pictures to control boxes using a loop, but don't know how to do this.

I want to set m_Pic1 - mPic12 and pic1 - pic12, but I don't know the function to evaluate this.

for(int i; i<12; i++){

// How do I set variables m_Pic1 and pic1 to increment?

m_Pic1.SetBitmap((HBITMAP)LoadImage(NULL,pic1(),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

}

Anyone help me on this?  Thanks in advance.
0
Comment
Question by:KAbbott
2 Comments
 
LVL 2

Expert Comment

by:jonnin
ID: 6868038
make an array of them, and loop through that.
alternately, make an array of pointers to all of them and loop through it instead; this will be easier in this situation I think...

0
 
LVL 4

Accepted Solution

by:
pagladasu earned 20 total points
ID: 6868372
Make these two #define statements at the begining of your program
#define m_Pic(x)     m_Pic##x
#define pic(x)          pic##x

then use it as follows:
for(int i = 1; i<13; i++){
m_Pic(i).SetBitmap((HBITMAP)LoadImage(NULL,pic(i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now