Let's discuss some of the fundamentals of DDE before building the application.
DDE server applications use DDE to broadcast data to one or more applications that have registered an interest in the data the server can provide. DDE client applications are the applications that receive data from the server.
DDE provides a two-way communication capability that also enables a client to send data to a server. This sometimes causes confusion. Just keep in mind that a DDE server can send data to multiple clients, but a DDE client can send data to only one server.
To get familiar with DDE, let's build an application that uses both the DDE server part and the DDE client part in the same window.
Create a new visual part named SameWindow consisting of two
Label parts and two Text parts. Make it look like the following:
You will add a DDE Server part so that text entered in the server text field is sent to any interested DDE clients.
Select the External Functions category, and then select
, the DDE Server part. Now add the part to an open space on the
free-form surface.
Open the settings for the DDE Server part. You will see a window
that looks like this:
DDE uses four strings to identify all information to be exchanged. The four strings are Server name, Topic, Item, and Format.
Note: | Double-byte characters are not supported for any of these strings. |
To complete the settings page, specify samewindow for the Server name, and then select New. Notice that a new row has been added to the table. Specify topic for Topic, item for Item, and string for Format.
Select OK to accept the changes to the settings page.
Complete the DDE server part by connecting it to the Server Text part. Select Connect > topic_item_string from the DDE Server pop-up menu.
The topic_item_string attribute is the concatenation, separated by underscores, of the Topic, Item, and Format specified in the DDE Server settings page. VisualAge added this to the public interface of the DDE Server part for you.
Complete the connection by connecting the topic_item_string attribute to the Server Text part's object attribute. Now the DDE Server will broadcast the contents of the Server Text part to any interested DDE clients whenever the Text part's object attribute changes. The broadcast will occur with each keystroke, because you accepted the default settings for the text part.