Solved

For looping

Posted on 2002-03-15
2
244 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Implementing a ResolveEventHandler in C++ 13 131
Prototype for MessageDlg in Embacadero XE 2 2 37
VS2015 compilation and missing DLLs 9 147
c++ syntax question 9 48
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

785 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