none
List dynamic global in a Windows Form C++

    General discussion

  • -- Hi everybody,

    I need help!

    I have created a Windows Form and in this one, I created two EditBox with one button to configure a linked list to save datas.
    In the first, I write the number of elements and in the second, I write the title of a piece. The button permit me to validate in order to create the list.
    li
    So I made a class, in files CPiece.h and CPiece.cpp, like that :
    ref
     class
     CPiece{
    
    private
    :
    
    UInt16 _INDEX ;
    String^ _SERIAL_NUMBER ;
    CPiece^ *_NEXT_PIECE ;
    
    public
    :
    
    CPiece() ;
    
    CPiece(int
     _INDEX, String^ _SERIAL_NUMBER) ;
    
    CPieceAddNextPiece(UInt16 _INDEX, String^ _SERIAL_NUMBER) ;
    
    } ;
    

    But I created the method to add a next piece like that :
    void
     CPiece::CPieceAddNextPiece(UInt16 _INDEX_PIECE, String^ _SERIAL_NUMBER){
    	CPiece^ *_NEW_PIECE ;
    	CPiece^ *_LAST_PIECE ;
    	
    	_NEW_PIECE = (CPiece^ *)malloc(sizeof
    (CPiece^)) ;
    	*_NEW_PIECE = gcnew CPiece(_INDEX_PIECE, _SERIAL_NUMBER) ;
    
    	if
    (this
    ->_NEXT_PIECE != NULL){
    		_LAST_PIECE = this
    ->_NEXT_PIECE ;
    		while
    ((*_LAST_PIECE)->_NEXT_PIECE != NULL){
    			_LAST_PIECE = (*_LAST_PIECE)->_NEXT_PIECE ;
    		}
    		(*_LAST_PIECE)->_NEXT_PIECE = _NEW_PIECE ;
    	}
    	else
    {
    		this
    ->_NEXT_PIECE = _NEW_PIECE ;
    	}
    }
    
    In my form1.h, I created a list of pieces with :
    static
     CPiece^ _LIST_OF_PIECES = gcnew CPiece() ;
    
    But when I click on my validate button, I have a loop of the number of pieces and I add a next piece at each round.
    During the execution of this event function, I have my linked list :
    _LIST_OF_PIECE -> PIECE(0, name) -> PIECE(1, name) -> PIECE(3, name) ...

    I have others components in my form and when I enter in an other event, I look the list and I just have :
    _LIST_OF_PIECE -> PIECE(0, name)

    Can you help me to have a global dynamic list with the parameters like in the class at the beginning of the question?

    Thanks, Best regards.
    Monday, May 04, 2009 6:51 AM