Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project i need to put the inserted data from an edit control in to a double liked list and then print all entries in a List Control.
My teacher told me to handle the data in a struct (so i'm not allowed to do this in a class). I put the struct in the ...Doc.h file. The struct looks like this:
C++
typedef struct adr
{
    char anrede [5];
    char vorname [51];
    char nachname [51];
    char plz [8];
    char ort [60];
    char strasse [51];
    char land [24];
    char festnetz [14];
    char mobil [14];
    char mail [101];
    char geburtsdatum [11];
    char kategorie [31];
    char startnummer [5];
    char startzeit [9];
    char zeit [9];
    char rang [5];
    char fahrrad [31];
    char sponsor [31];
} adressen;

struct node
{
    adressen *konto;
    struct node *prev;
    struct node *next;
};

Every struct field has its own edit control. The edit controls got a limited amount of character. So you cannot insert to many characters for the struct fields. The datatype of the edit controls is CString and they are named like:
C++
m_anrede
m_vorname
m_nachname
m_plz
m_ort
m_strasse
m_land
m_festnetz
m_mobil
m_mail
m_geburtsdatum
m_kategorie
m_startnummer
m_startzeit
m_zeit
m_rang
m_fahrrad
m_sponsor

The edit controls are placed in a dialog wich is named by DlgAdd.

Now i need to insert the data from the input dialog in the double linked list with the struct which is placed in the ...Doc.h file and then print all entries in a list control the wole code should be in the View.cpp file.
I need hints and tricks to do this, thanks a lot
Posted

You have a big task, and need it to split in little tasks. My first advice, is to write some helper functions for filling the struct. Like
C++
void setAnrede( adressen*data, const char* anrede ) {
  strncpy( data->anrede, anrede, 5 - 1 );//use maximal allowed space minus 1 (for the delimeter)
} 

This helps avoiding problems and it is really worth the time.

Then you need to tackle double linked list with this tutorial.

For the dialog problems can should read this article: Dialog Data Exchange in MFC and try the code.

My advice to you: "Ohne Fleiß kein Preis." ;-)
 
Share this answer
 
You don't need hint and trick at all, just a plain transfer of values from the edit controls to struct's member. You may use GetWindowText[^] if your member varaibles are CEdit pointers or directly copy the strings if your member varaiables are CStrings.

Please note C++ struct are basically classes. The only difference is the default access level of their members.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900