Click here to Skip to main content
14,173,730 members
Rate this:
 
Please Sign up or sign in to vote.
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:
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:
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
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." ;-)
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190524.3 | Last Updated 4 Nov 2015
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100