Click here to Skip to main content
15,924,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Inline Assembler in Dev-C++ Pin
Dominik Reichl8-Sep-02 1:10
Dominik Reichl8-Sep-02 1:10 
GeneralRe: Inline Assembler in Dev-C++ Pin
Rene De La Garza13-Sep-02 10:20
Rene De La Garza13-Sep-02 10:20 
QuestionWhat kind of array ? Pin
Daniel Strigl7-Sep-02 9:04
Daniel Strigl7-Sep-02 9:04 
AnswerRe: What kind of array ? Pin
Joaquín M López Muñoz7-Sep-02 9:15
Joaquín M López Muñoz7-Sep-02 9:15 
AnswerRe: What kind of array ? Pin
Christian Graus7-Sep-02 13:50
protectorChristian Graus7-Sep-02 13:50 
QuestionWhat kind of array ??? Pin
Daniel Strigl7-Sep-02 8:57
Daniel Strigl7-Sep-02 8:57 
AnswerRe: What kind of array ??? Pin
Daniel Turini7-Sep-02 9:11
Daniel Turini7-Sep-02 9:11 
AnswerRe: What kind of array ??? Pin
Raphael Kindt7-Sep-02 12:11
Raphael Kindt7-Sep-02 12:11 
Hi...

With MFC you've 3 types of simple container
1. Array : with CArray
2. List : with CList (very useful)
3. Map : with CMap
You've also containers of typed pointers. For example CTypedPtrList

With CArray, use this command for an array of CPoint named PointArray
CArray<CPoint, CPoint&> PointArray;
To add a point:
PointArray.Add(aPoint);
Advice: It's recommended to use the method SetSize() for initialize the size of the array and avoid a lot of reallocation.
To extract an element:
aPoint = PointArray.GetAt(2);
To change an element:
PointArray.SetAt(3, NewPoint); // stock the NewPoint in the place of the 4th element

But I find CList more useful...
With CList, use this comand for a list of CPoint named PointList
CList<CPoint, CPoint&> PointList;
To add a point:
PointList.AddTail(aPoint); // in the end of the list
PointList.AddHead(aPoint); // in the head of the list
To insert a point:
PointList.InsertBefore(aPosition, ThePoint); // before the aPosition (type = POSITION)
PointList.InsertAfter(aPosition, ThePoint); // afterthe aPosition (type = POSITION)
The GetNext() return a value of type POSITION which is the position of the next pointed element.
For an iteration inside the list use this loop:
CPoint CurrentPoint(0,0);<br />
POSITION aPosition = PointList.GetHeadPosition();<br />
while(aPosition)<br />
{<br />
   CurrentPoint = PointList.GetNext(aPosition);<br />
   // ... use of CurrentPoint ...<br />
}


For more information... MSDN of course (but it's really a mess)


Hello World!!! Smile | :)
from Raphaël
GeneralRe: What kind of array ??? Pin
Christian Graus7-Sep-02 13:52
protectorChristian Graus7-Sep-02 13:52 
GeneralRe: What kind of array ??? Pin
Raphael Kindt8-Sep-02 0:18
Raphael Kindt8-Sep-02 0:18 
AnswerRe: What kind of array ??? Pin
Raphael Kindt7-Sep-02 12:12
Raphael Kindt7-Sep-02 12:12 
QuestionTrying to do this with ADO only? Possible? Pin
ns7-Sep-02 8:38
ns7-Sep-02 8:38 
AnswerRe: Trying to do this with ADO only? Possible? Pin
Michael P Butler7-Sep-02 11:06
Michael P Butler7-Sep-02 11:06 
GeneralRe: Trying to do this with ADO only? Possible? Pin
nss7-Sep-02 11:32
nss7-Sep-02 11:32 
GeneralRe: Trying to do this with ADO only? Possible? Pin
Michael P Butler7-Sep-02 11:48
Michael P Butler7-Sep-02 11:48 
GeneralRe: Trying to do this with ADO only? Possible? Pin
nss7-Sep-02 12:55
nss7-Sep-02 12:55 
GeneralRe: Trying to do this with ADO only? Possible? Pin
nss7-Sep-02 13:01
nss7-Sep-02 13:01 
GeneralRe: Trying to do this with ADO only? Possible? Pin
nss7-Sep-02 13:04
nss7-Sep-02 13:04 
GeneralRe: Trying to do this with ADO only? Possible? Pin
nss7-Sep-02 13:23
nss7-Sep-02 13:23 
GeneralFew more questions Pin
nss7-Sep-02 13:35
nss7-Sep-02 13:35 
GeneralRe: Few more questions Pin
Michael P Butler7-Sep-02 20:56
Michael P Butler7-Sep-02 20:56 
AnswerRe: Trying to do this with ADO only? Possible? Pin
JT Anderson9-Sep-02 5:29
JT Anderson9-Sep-02 5:29 
Generalredefinition problems Pin
ns7-Sep-02 8:26
ns7-Sep-02 8:26 
GeneralRe: redefinition problems Pin
Joaquín M López Muñoz7-Sep-02 9:33
Joaquín M López Muñoz7-Sep-02 9:33 
GeneralCP's CADOX class (CArlos Antollini) Pin
ns7-Sep-02 8:06
ns7-Sep-02 8:06 

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.