Dynamic Data Exchange Demos Horizon Technologies Inc. Overview: The Dynamic Data Exchange (DDE) demo programs illustrate the concept of inter-program communications in a Microsoft Windows environment. Source code for three programs is included. All interactions between these programs are accomplished via the process of message passing in accordance with the DDE protocol defined by Microsoft. A dynamic link library, DDELIB, developed by Horizon Technologies Inc., has been utilized in each of these programs to significantly reduce development time and program complexity. The following material builds upon the information presented in the Overview of the DDELIB documentation. AccExcel: ACCEXCEL is a menu driven application that shows the basics of a DDE connection to EXCEL. EXCEL is a popular Windows spreadsheet application written by Microsoft. The ACCEXCEL pull-down menu "DDE" lists four items; Initiate, Poke, Advise and Terminate. Initiate will establish a DDE session with a spreadsheet in EXCEL. The name of the spreadsheet is entered into a dialog box presented by ACCEXCEL. Poke will send data to the spreadsheet. A dialog box will allow the specification of the cell range and the comma separated data values. Advise will set up an advise circuit with a cell range in EXCEL. When any data is modified in this range, EXCEL will advise ACCEXCEL which in turn will display a message box with the modified data. Terminate simply closes the DDE session established with Initiate. Sub: SUB is a DDE client application that talks to the server application FISH. FISH, supplied by Microsoft, displays fish swimming in a tank. When FISH establishes a session with a client, it reveals a yellow submarine. This submarine can then be manipulated by the client to move up, down, left, right and even fire a torpedo. To augment this capability, the client can also obtain the current position of a fish in x,y coordinates. With a simple sneak-up-from-behind-and-fire strategy, SUB easily controls the submarine in a mission to liquidate fish. Dynamic Data Exchange Demos - Copyright (C) 1990 Horizon Technologies Inc. All rights reserved. (517) 347-0800 1 Technically, SUB initiates two sessions with fish; one for sub control and reporting, the other for fish position monitoring. A DDE advise circuit for fish number zero is established. The callback routine Fish() is called by DDELIB every time the fish moves. In this routine, a request for the current sub position is made. This results in a callback to the Sub() routine. Once the current fish and sub positions are known, a call to MoveSub() is made. Here, a command is sent to the sub for positioning and firing. Note that the sub must be moving up or down, left or right. Therefore, if the sub needs to maintain elevation, it must oscillate up and down. Session and SessUtil: SESSION is a DDE server application that provides a means for clients to store and retrieve string variable contents by name. SESSION accepts DDE pokes, requests, and advises. Commands are not supported. SESSION accomplishes this by registering the topic Variables. The callback routine Session() is invoked by DDELIB every time a new client establishes a session, terminates a session, pokes or requests data, establishes an advise circuit, or sends a command. SESSION processes these events to provide its services, such as saving the contents of a poke or advising a client of a change in the variable. SESSUTIL is a DDE client application that communicates with the SESSION application. SESSUTIL shows the current contents of the User variable, as provided by SESSION, on its client area. The user can set the contents of the User variable by selecting the Modify item from the File menu. The new value is displayed on every instance of SESSUTIL running. SESSUTIL initially establishes a DDE advise circuit with SESSION on the variable User. This causes the callback routine User() to be invoked by DDELIB whenever SESSION performs an advise. User() will update its own copy of the value and then force a repaint of the client area, resulting in the new value of the User variable to be displayed. When the user selects OK from the modify dialog box, the Poke() routine is called. This sends the new variable to SESSION, which in turn advises SESSUTIL, which then displays the new value. Microsoft Word for Windows can eavesdrop in on the conversation, displaying the current contents of the User variable. Simply insert a field of the form {ddeauto SESSION Variables User}. Dynamic Data Exchange Demos - Copyright (C) 1990 Horizon Technologies Inc. All rights reserved. (517) 347-0800 2