VA Smalltalk DDE client
From a VA Smalltalk perspective, using DDE as a client to exchange data with another application is no different from using DDE to exchange data with another VA Smalltalk application. As a DDE client, the application will need to connect to the server and identify the desired topic, items, and formats from among those that the DDE server application supports. Consult the documentation that comes with the DDE server application to determine what it supports. When documentation is unavailable or unclear, try running the DDE server application while constructing your client. As long as the other application is a well-behaved DDE server, VA Smalltalk will be able to help you fill in the DDE client settings page appropriately.
In the following example, we will exchange data between a VA Smalltalk DDE client and a Microsoft Excel DDE server.
Building the visual part
Create a new visual part named ExcelServerVAClient. Use a Multi-line Edit part and a DDE Client part to construct a window that looks like the following:
DDE example
On page one of the General settings for the DDE Client part, specify Excel for the Server name and ddeserv.xls for the Topic. The name of the spreadsheet we will use is ddeserv.xls. Select New item. In the table row that was just added, specify tonga for the Item, and string for the Format. Select OK to accept the changes to the settings page.
Connect the Multi-line Edit part's object attribute to the DDE Client part's tonga_string attribute. This will enable us to set the contents of the Multi-line Edit part with the data received from Excel.
Connect the Window part's aboutToOpenWidget action to the DDE Client part's connect action. This will establish the DDE connection to the Excel server when the client is started.
Connect the Window part's aboutToCloseWidget action to the DDE Client part's disconnect action. This will break the DDE connection to the Excel server when the Window part is closed.
Save your work.
Testing your window
Start Microsoft Excel. Select a cell in the spreadsheet and then select Define name from the Formula. Type tonga in the Name field and select OK. Save the file as ddeserv.xls. Now, type some text into the tonga cell.
In the Composition Editor select Test iconto test your window.
The text you typed into the tonga cell will appear in the Multi-line Edit part. Try closing the spreadsheet. You will receive a warning notifying you that DDE connections exist. Cancel out of this process and then close your DDE client window. Try closing the spreadsheet again. This time you will not see the previous warning. This is because the DDE client disconnected when the window was closed. When you are done testing, close Microsoft Excel.
Last modified date: 06/12/2018