Click here to Skip to main content
15,914,608 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHElp!! Pin
V.G15-Oct-04 2:44
V.G15-Oct-04 2:44 
GeneralHElp!! Pin
V.G15-Oct-04 2:46
V.G15-Oct-04 2:46 
Generalarray of components 2d Pin
K.A.L13-Oct-04 2:56
K.A.L13-Oct-04 2:56 
GeneralRe: array of components 2d Pin
David Crow13-Oct-04 3:22
David Crow13-Oct-04 3:22 
GeneralRe: array of components 2d Pin
K.A.L13-Oct-04 8:57
K.A.L13-Oct-04 8:57 
GeneralRe: array of components 2d Pin
David Crow13-Oct-04 9:03
David Crow13-Oct-04 9:03 
GeneralRe: array of components 2d Pin
K.A.L14-Oct-04 3:58
K.A.L14-Oct-04 3:58 
GeneralRe: array of components 2d Pin
Kevin McFarlane13-Oct-04 6:33
Kevin McFarlane13-Oct-04 6:33 
Avoid raw arrays. I would use CArray or vector, eg., (in your case substitute PictureBox for int)

// ***************************************
// Example: Dynamic Multidimensional Array
// ***************************************
// We want both array dimensions to be allocated dynamically and
// to be able to reference an element as x[i][j]
// Here's how to do it...
// ***********
// MFC Version
// ***********
// Array of ints
typedef CArray <int, int> CIntArray;
// Array of arrays of ints
typedef CArray <CIntArray, CIntArray&> CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;

// Allocate number of rows
aTest.SetSize( rows );

// For each row
for (int row = 0; row < aTest.GetSize(); row++)
{
// Allocate number of columns
aTest[row].SetSize( columns );

// For each column
for (int column = 0; column < aTest[row].GetSize(); column++)
{
// Assign a value
aTest [row] [column] = 10 * row + column;

// Trace it
afxDump << aTest [row] [column] << "\t";
}
afxDump << "\n";
}
}
// ****************************
// Standard C++ Library Version
// ****************************
// Array of arrays of ints
typedef vector<vector<int> > CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;
// Allocate number of rows
aTest.resize( rows );

// For each row
for (int row = 0; row < aTest.size(); row++)
{
// Allocate number of columns
aTest[row].resize( columns );

// For each column
for (int column = 0; column < aTest[row].size(); column++)
{
// Assign a value
aTest [row] [column] = 10 * row + column;

// Trace it
cout << aTest [row] [column] << "\t";
}
cout << "\n";
}
}
// Example usage: Standard C++ Library version
int main(int argc, char* argv[])
{
TraceDynamicArray(3,5);
return 0;
}
// For rows = 3, columns = 5, produces output...
// 0 1 2 3 4
// 10 11 12 13 14
// 20 21 22 23 24


Kevin
GeneralRe: array of components 2d Pin
K.A.L13-Oct-04 9:01
K.A.L13-Oct-04 9:01 
GeneralRe: array of components 2d Pin
Kevin McFarlane13-Oct-04 22:36
Kevin McFarlane13-Oct-04 22:36 
GeneralRe: array of components 2d Pin
K.A.L14-Oct-04 3:57
K.A.L14-Oct-04 3:57 
GeneralHelp ! hook java application by VC++ Pin
crazymanhehe13-Oct-04 1:32
susscrazymanhehe13-Oct-04 1:32 
GeneralCreating Server application using CAsyncSocket Pin
prasanna kankanalapalli13-Oct-04 0:52
prasanna kankanalapalli13-Oct-04 0:52 
GeneralInterfacing with C# .net web service from C++ .net Pin
Member 131514813-Oct-04 0:31
Member 131514813-Oct-04 0:31 
Generalagain IContextMenu Pin
mazur197313-Oct-04 0:01
mazur197313-Oct-04 0:01 
QuestionRealTime Priority? Pin
Manikandan12-Oct-04 23:40
Manikandan12-Oct-04 23:40 
AnswerRe: RealTime Priority? Pin
Arsalan Malik13-Oct-04 2:07
Arsalan Malik13-Oct-04 2:07 
AnswerRe: RealTime Priority? Pin
Antony M Kancidrowski13-Oct-04 2:33
Antony M Kancidrowski13-Oct-04 2:33 
GeneralRe: RealTime Priority? Pin
Manikandan13-Oct-04 5:22
Manikandan13-Oct-04 5:22 
GeneralRe: RealTime Priority? Pin
Antony M Kancidrowski13-Oct-04 5:33
Antony M Kancidrowski13-Oct-04 5:33 
GeneralRe: RealTime Priority? Pin
Manikandan13-Oct-04 6:20
Manikandan13-Oct-04 6:20 
GeneralRe: RealTime Priority? Pin
Antony M Kancidrowski13-Oct-04 11:41
Antony M Kancidrowski13-Oct-04 11:41 
AnswerRe: RealTime Priority? Pin
geo_m13-Oct-04 21:42
geo_m13-Oct-04 21:42 
GeneralRe: RealTime Priority? Pin
Manikandan13-Oct-04 21:51
Manikandan13-Oct-04 21:51 
GeneralRe: RealTime Priority? Pin
geo_m14-Oct-04 0:28
geo_m14-Oct-04 0:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.