In the Composition Editor, you can make connections from controls to predefined functions, such as removing the selected entry from a list or adding the value of an entry field to a list. For the Review Tool User Administration program, these simple connections are not sufficient, because additional processing needs to take place (for example, the user you delete needs to be deleted from the file containing the list of users).
In this section you will make connections in the Composition Editor from the Delete button to member functions of the MyGui class. You will then code these functions in the VisualAge C++ IDE.
Create Multiple Connections for the Delete Push Button
The Delete button will remove the selected entry from the list of users, and should remove that user's information from the user information file. You could implement this as a single connection to a single member function. This would make the connections in the Composition Editor simpler, but would involve more user-written code. Instead, you will make two connections for this button. The first will call a member function you will code, to remove the entry from the user file. The second will use a built-in action, the Remove action, to remove the entry from the displayed list.
Because both connections involve the selected item in a list of items, the order in which the connections are called is important. If the Remove action occurs before your member function is called, the selected entry in the list will no longer exist, so you will not be able to determine which element to remove from your array of users. If you create the custom connection first, it will be called first in the executable file, so you will avoid this problem. (You can re-order connections later if you need to; see Reordering Connections in the VisualAge C++ Tasks help.)
Follow these steps to create the user-defined member function connection:
Follow these steps to create the Remove action that will delete the entry from the displayed list:
You should now see two green arrows, both starting at the Delete button.
Select the second connection arrow (pointing to the list box) so that three square handles appear. Select the middle square and drag it away from the other two squares, to make the two parts of the line longer. You will notice that this connection line, unlike the others created so far, appears dashed. The Composition Editor displays a dashed line for any connection that is incomplete. The connection is incomplete because you have not indicated what to remove from the list. The Remove action requires an index parameter to tell it what to remove; you need to set this index parameter to the item selected in the listbox.
Follow these steps to complete the connection:
The connection is now complete. However, the work for the Delete button is not finished. You still need to define the DeleteUser function so that the selected item is removed from the user information file before it is removed from the list box. You also need to make connections for the other buttons. You will do this work in Part 8. Defining Functions for Custom Connections
