Solved

For looping

Posted on 2002-03-15
2
236 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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

10 Experts available now in Live!

Get 1:1 Help Now