Building the server window
In the Organizer window, create a new application named ShoppingList and then create a new visual part named ShoppingServerView.
Use a Text part, a single-selection List part, and two Push button parts to create the server window part as shown in the figure in
Using DDE with Smalltalk objects.
Specifying the DDE server settings
Now add a DDE Server part, because this window will be the server. On page one of the General settings for the DDE Server part, specify ShoppingListServer for the Server name. Click New twice to create two new rows in the table. In the first table row, specify shopping for the Topic, groceryitem for the Item, and string for the Format. In the second table row, specify shopping for the Topic, grocerylist for the Item, and smalltalk object for the Format. On page 2 of the General settings, check Clients in same application as server.
Select OK to accept the changes to the settings page.
Making the connections
The objective, visually, is to be able to add items in the Text part to the List part. We also want to be able to remove the selected item from the List part whenever the user selects the Remove push button.
To accomplish all this, add an Ordered Collection part and make the connections as follows:
1. Connect the Ordered Collection part's self attribute to the List part's items attribute.
2. Connect the Add push button's clicked event to the Ordered Collection part's add: action.
3. Connect the Text part's object attribute to the anObject attribute of the connection you created in the previous step.
4. Connect the Remove push button's clicked event to the Ordered Collection part's remove: action.
5. To specify the connection's parameter, connect the List part's selected item attribute to the anObject attribute of the connection you created in the previous step.
The objective with the DDE Server part is to provide the contents of the Text part, or the contents of the List part, or both, to any interested DDE client. To accomplish this, make the connections to the DDE Server part as follows:
1. Connect the Text part's object attribute to the DDE Server part's shopping_groceryitem_string attribute. This will forward the contents of the Text part, keystroke by keystroke, as a string to any interested DDE client.
2. Connect the List part's items attribute to the DDE Server part's shopping_grocerylist_smalltalk object attribute. This will forward the List part as a Smalltalk object to any interested VA Smalltalk DDE client.
Save your work and test it.
Try adding a few items to the list by typing in the Text part and selecting Add. Each item should be added to the list. Select an item in the list and then select Remove. The selected item should be removed from the list.
After your window is working properly, leave it running. This will allow us to explore some of the ways VA Smalltalk makes it easy to build a DDE client in the next section.
Last modified date: 06/12/2018