-
September 11th, 2009, 06:22 AM
#1
Decleration of 2d array of CStatic*
Hi All..
Im trying to re-develop my C++ skills and have a little project in which I want to declare, fill and create a 2d array of CStatic pointers then draw them on a dialog box in a grid pattern.
Can anyone help me with the correct syntax please.
Thank you for your time !
Phill
-
September 11th, 2009, 07:48 AM
#2
Re: Decleration of 2d array of CStatic*
What's the problem? Why pointers; why not CStatic itself? Is the grid fixed, or does it vary with the size of the dialog, etc.? Why not use a control more amenable to grids such as a CListCtrl?
-
September 11th, 2009, 10:22 AM
#3
Re: Decleration of 2d array of CStatic*
Hi...
Well the grid (or table) will vary in size depending on the user. It doesnt have to be a 2d array, but I would like to access it using co ordinates i.e GetAt(3,4) etc. Having created it I just want to change the text in it and perhaps the background colour.
Thanks anyway !
Phill
-
September 11th, 2009, 10:48 AM
#4
Re: Decleration of 2d array of CStatic*
I still don't understand. This is just simple algebra. Do you just want someone to do all the work for you, or is there some concept you don't understand?
-
September 11th, 2009, 11:19 AM
#5
Re: Decleration of 2d array of CStatic*
OK..
So I have a single dimension array of 144 CStatics created like this
SlabRect.left = 50;
SlabRect.top = 50;
SlabRect.right = 100;
SlabRect.bottom = 100;
for(i=0; i<m_NumberGrid.GetSize(); i++)
{
delete m_NumberGrid.ElementAt(i);
}
m_NumberGrid.SetSize(0);
for(i=0; i<(m_GridXSize * m_GridYSize); i++)
{
m_NumberGrid.Add(new CStatic());
((CStatic*)m_NumberGrid.ElementAt(i))->Create(" ",WS_CHILD |WS_BORDER|WS_VISIBLE, SlabRect, this);
}
What I dont understand is how I can draw them in a table of 12 x12, and having done that, access each of the windows pointers using co-ordinates such as GetAt(4,5).
Im sure it is a simple matter of algebra, but Im afraid its not as simple as it used to be for me.
-
September 11th, 2009, 12:44 PM
#6
Re: Decleration of 2d array of CStatic*
for a zero based x by y array of width columns
Code:
element = x * width + y
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|