Windows Development Dynadata 129 Copyright 2014 Dyna Data

  • Slides: 29
Download presentation
Windows Development Dynadata 1/29 Copyright, 2014 © Dyna. Data S. A.

Windows Development Dynadata 1/29 Copyright, 2014 © Dyna. Data S. A.

Data Exchange Dynadata 2/29 Copyright, 2014 © Dyna. Data S. A.

Data Exchange Dynadata 2/29 Copyright, 2014 © Dyna. Data S. A.

Data Exchange Overview • • • Clipboard Dynamic Data Exchange (DDE) Component Object Model

Data Exchange Overview • • • Clipboard Dynamic Data Exchange (DDE) Component Object Model Object Linking and embedding (OLE) Structured Storage Active technologies Automation COM and MFC ATL Dynadata 3/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard I The most common means of inter application communication is the Clipboard. Dynadata

Clipboard I The most common means of inter application communication is the Clipboard. Dynadata 4/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard II The process is initiated by the user and has a very simple

Clipboard II The process is initiated by the user and has a very simple protocol. When the user requests a cut or copy operation to place data in the Clipboard, the application makes application programming interface (API) calls to empty the Clipboard and then to send data to it. The application provides the single item of data in as many formats as it can, so as to increase the likelihood that the eventual recipient will understand one of them. Dynadata 5/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard III Possible problems of using huge amounts of system resources in rendering your

Clipboard III Possible problems of using huge amounts of system resources in rendering your application's data in many different formats can be avoided by employing the delayed rendering technique. Dynadata 6/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard IV Using this technique allows the provider of the data to simply list

Clipboard IV Using this technique allows the provider of the data to simply list the formats it supports, but only to have to render the data when another application actually tries to take it from the Clipboard. In this way, data that is never going to be used never needs to be rendered. When the user makes a paste request, the receiving application enumerates the formats of the data in the Clipboard and, having found one it likes, takes the data. Dynadata 7/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard Standard Formats I It’s possible to transfer objects in one of a number

Clipboard Standard Formats I It’s possible to transfer objects in one of a number of standard formats through the Clipboard or a private data type specific to an application or set of applications. Dynadata 8/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard Standard Formats II It’s possible to transfer objects in one of a number

Clipboard Standard Formats II It’s possible to transfer objects in one of a number of standard formats through the Clipboard or a private data type specific to an application or set of applications. Dynadata 9/29 Copyright, 2014 © Dyna. Data S. A.

Clipboard Private Formats Windows provides a mechanism to register the names of private formats

Clipboard Private Formats Windows provides a mechanism to register the names of private formats at run time. Publishing the format means creating a document that gives details of the format and describes how it should be used. Dynadata 10/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange (DDE) DDE is a protocol that allows two applications to exchange

Dynamic Data Exchange (DDE) DDE is a protocol that allows two applications to exchange data in a format they both understand. These two programs are known as the “server” and the “client”. A single Windows program can be both a client to one program and a server to another, but this requires two different DDE conversations. Dynadata 11/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange (DDE) II A server can delivery data to multiple clients, and

Dynamic Data Exchange (DDE) II A server can delivery data to multiple clients, and a client can obtain data from multiple servers, but again, this requires multiple DDE conversations. The DDE protocol was originally implemented using a set of Windows messages and the same set of data formats that the Clipboard uses. Dynadata 12/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange (DDE) III To keep each conversation the DDE protocol uses a

Dynamic Data Exchange (DDE) III To keep each conversation the DDE protocol uses a different window. When a client asks a server for data, it must be able to identify the type of data it wants. A program involved in a DDE conversation need not be specially coded to work with each other. Dynadata 13/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange (DDE) (types of conversation) • Cold Link • Hot Link •

Dynamic Data Exchange (DDE) (types of conversation) • Cold Link • Hot Link • Warm Link Dynadata 14/29 Copyright, 2014 © Dyna. Data S. A.

Initiating DDE Conversation A DDE conversation is initiated by the client program. The client

Initiating DDE Conversation A DDE conversation is initiated by the client program. The client broadcast a message (called WM_DDE_INITIATE) to all current running Windows programs. A DDE server that has this data can respond to this broadcast message and the conversation begins. Dynadata 15/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Type of Data The DDE protocol identifies the units of data passed

The DDE Type of Data The DDE protocol identifies the units of data passed between the client and server with a three-level hierarchy of application, topic, and item names. • Application name (the name of the server application) • Topic name (general classification of data within which multiple data items ) • Item name (information related to the conversation topic ) Dynadata 16/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Type of Data II The application name and topic that define a

The DDE Type of Data II The application name and topic that define a conversation cannot be changed during the course of the conversation. Values for the data item can be passed from the server to the client, or from the client to the server Data can be passed with any of the standard clipboard formats or with a registered clipboard format. A special, registered format named Link identifies an item in a DDE conversation. Dynadata 17/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange (DDE) Server application answer diagram Dynadata 18/29 Copyright, 2014 © Dyna.

Dynamic Data Exchange (DDE) Server application answer diagram Dynadata 18/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link I WM_DDE_INITIATE A Cold Link conversation begins when a client

The DDE Cold Link I WM_DDE_INITIATE A Cold Link conversation begins when a client broadcast a WM_DDE_INITIATE message identifying the application and the topic it requires. The application and topic may be NULL to begin a conversation with any server application or any data topic. Dynadata 19/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link II WM_DDE_INITIATE A server that supports the specified topic respond

The DDE Cold Link II WM_DDE_INITIATE A server that supports the specified topic respond to the client with a WM_DDE_ACK message. Client WM_DDE_INITIATE (application, topic) Server WM_DDE_ACK Dynadata 20/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link I WM_DDE_REQUEST • The client then request a WM_DDE_REQUEST message.

The DDE Cold Link I WM_DDE_REQUEST • The client then request a WM_DDE_REQUEST message. • If the server can supply this data item, it responds by posting a WM_DDE_DATA message to the client. Client particular WM_DDE_REQUEST (item) data item by posting a Server WM_DDE_DATA (item) WM_DDE_ACK (positive) Dynadata 21/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link II WM_DDE_REQUEST The client must acknowledge to the server that

The DDE Cold Link II WM_DDE_REQUEST The client must acknowledge to the server that it has received the WM_DDE_DATA message if the server asked this acknowledgment in a flag passed with the WM_DDE_DATA message. A flag passed with the WM_DDE_ACK message indicates a "positive" acknowledgment. Dynadata 22/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link III WM_DDE_REQUEST If the client post a WM_DDE_REQUEST message to

The DDE Cold Link III WM_DDE_REQUEST If the client post a WM_DDE_REQUEST message to the server, and the server cannot supply the request data item, then the server post a “negative” WM_DDE_ACK message to the client. Client WM_DDE_REQUEST (item) Server WM_DDE_ACK (negative) The DDE conversation continues with the client for the same data item or different data item. . . Dynadata 23/29 Copyright, 2014 © Dyna. Data S. A.

The DDE Cold Link WM_DDE_TERMINATE The conversation is terminated when the client and server

The DDE Cold Link WM_DDE_TERMINATE The conversation is terminated when the client and server post each other WM_DDE_TERMINATE message. Client WM_DDE_TERMINATE Server WM_DDE_TERMINATE The server can post the first WM_DDE_TERMINATE message and the client must respond to that. Dynadata 24/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange Management Library (DDEML) I More recently, the Dynamic Data Exchange Management

Dynamic Data Exchange Management Library (DDEML) I More recently, the Dynamic Data Exchange Management Library DDEML API set was introduced to provide isolation both from the actual protocol and also from the implementation of the protocol under Windows. Dynadata 25/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange Management Library (DDEML) II The DDEML is a dynamic-link library (DLL)

Dynamic Data Exchange Management Library (DDEML) II The DDEML is a dynamic-link library (DLL) that Win 32 based applications can use to share data. The DDEML provides functions and messages that simplify the task of adding DDE capability to a Win 32 -based application. Instead of sending, posting, and processing DDE messages directly, an application uses the DDEML functions to manage DDE conversations. (A DDE conversation is the interaction between client and server applications. ) Dynadata 26/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange Management Library (DDEML) III Existing applications that use the message-based DDE

Dynamic Data Exchange Management Library (DDEML) III Existing applications that use the message-based DDE protocol are fully compatible with those that use the DDEML. That is, an application that uses message-based DDE can establish conversations and perform transactions with applications that use the DDEML. Dynadata 27/29 Copyright, 2014 © Dyna. Data S. A.

Dynamic Data Exchange Management Library (DDEML) IV Because of the many advantages of the

Dynamic Data Exchange Management Library (DDEML) IV Because of the many advantages of the DDEML, new applications should use it rather than the DDE messages. To use the API elements of the DDEML, you must include the DDEML header file in your source files, link with the DDEML library, and ensure that the DDEML dynamic-link library is in the system's search path. Dynadata 28/29 Copyright, 2014 © Dyna. Data S. A.

Terminating DDE Conversation • A DDE conversation is initiated by the client program. •

Terminating DDE Conversation • A DDE conversation is initiated by the client program. • The client broadcast a message (called WM_DDE_INITIATE) to all current running Windows programs. • A DDE server that has this data can respond to this broadcast message and the conversation begins. Dynadata 29/29 Copyright, 2014 © Dyna. Data S. A.