Transferring Information

As explained in Dropping an Object, a target window may send a DM_RENDER message to the source when it receives a DM_DROP message from Presentation Manager. Similarly, a Workplace Shell object may send the same message when its _wpDrop method is invoked by the Workplace Shell. This message is normally sent to the source when the target requires the assistance of the source in completing the transfer of data as part of the drop operation.

The source window processes this message in its window procedure, according to the rendering mechanism requested by the target. If the source is a Workplace Shell object, the Workplace Shell will directly invoke the object's _wpRender method to perform the same function. In most cases, however, an object does not need to override the _wpRender method unless it wishes to implement a private rendering mechanism.

The DM_RENDER processing from the Customer program is shown in Figure "Handling the DM_RENDER Message".

The first parameter to the DM_RENDER message contains a pointer to the DRAGTRANSFER structure, which in turn contains a pointer to the DRAGITEM structure in its pditem field. For a Workplace Shell object, a pointer to the DRAGTRANSFER structure is passed as a parameter to the _wpRender method.

In the DRM_SHAREMEM rendering mechanism, the ulItemID field in the DRAGITEM structure is used to hold a pointer to the customer container record (of type CONTRECORD), in whch the cust field is a CUSTOMER structure containing details of the customer object which was dragged.

Next, the name of the shared memory object previously allocated by the target window is retrieved from the hstrRenderToName field of the DRAGTRANSFER structure. This name is used to obtain access to the shared memory object. The customer details are copied into this memory object, after which the memory object is freed.

The operation code in the DRAGTRANSFER structure is then checked to establish whether the target requires a copy or a move operation. If a move was requested, the source program deletes the customer record from the contaiiner by calling an application subroutine named RemoveCustomer().

The window procedure then returns the value TRUE, indicating that the data was successfully rendered. This value is returned to the target window procedure that issued the DrgSendTransferMsg() call. At this point, the target window procedure has access to all information required to complete the drop operation, and may do so without further communication.

At the completion of the rendering procedure, the source may pass a DM_RENDERCOMPLETE message to the target, allowing the target to release any resources still outstanding. A Presentation Manager window may process this message in its window procedure, while a Workplace Shell object is notified of the event by the Workplace Shell, which invokes the object's _wpRenderComplete method. This is usually only required in cases where complex private rendering mechanisms involve multiple transfers. It is not used in the above examples.


[Back: Dropping an Object]
[Next: Using Rendering Mechanisms]