The following sections describe the use of two of the standard rendering mechanisms, DRM_PRINT and DRM_OS2FILE. These mechanisms can be used by Presentation Manager applications to interact with other applications and/or Workplace Shell objects.
DRM_PRINT
For Presentation Manager applications running on the Workplace Shell desktop under OS/2 Version 2.0, it may be desirable to allow the user to print from the program by dragging the relevant item, such as a customer record, onto a Workplace Shell printer object. Since all Workplace Shell printer objects are written to understand the DRM_PRINT rendering mechanism, a Presentation Manager may provide such function simply by adhering to this mechanism.
With the DRM_PRINT rendering mechanism, responsibility for actually carrying out the printing rests within the source window. The source window must:
The first three steps are handled in exactly the same way as illustrated in Figure "Drag Initiation From a Container Window". Note that a view of a Workplace Shell object need not explicitly handle Presentation Manager messages in the window procedures for its views. When the user initiates a drag from within a Workplace Shell object such as a folder or work area, the object is notified by the Workplace Shell, which invokes the object's _wpFormatDragItem method. This method is processed in an identical manner to that shown for the window procedure in Figure "Drag Initiation From a Container Window".
The final step is handled by processing the DM_PRINTOBJECT message in the source window procedure. A simple example of such processing is shown in Figure "Receiving a DM_PRINTOBJECT Message".
DRM_DISCARD
The DRM_DISCARD rendering mechanism operates in a similar fashion to the DRM_PRINT mechanism, and is intended for use by applications which create their own equivalent to the Workplace Shell Shredder object. In this rendering mechanism, the target passes a DM_DISCARDOBJECT message to the source, which may either accept responsibility for the discard operation, abort the operation, or allow the system to perform the operation.
Note that the system may only discard objects which are capable of being rendered with the DRM_OS2FILE rendering mechanism; that is, program files and data files. Other objects not based upon files must be explicitly discarded by the source.
When a Workplace Shell object is dropped on the Shredder object, the Workplace Shell intercepts the DM_DISCARDOBJECT message and invokes the source object's wpDelete method.
DRM_OS2FILE
The DRM_OS2FILE rendering mechanism is designed to support moving and copying file objects between containers. This rendering mechanism is described in detail in the OS/2 2.0 Programming Guide Volume II, and an extensive example is provided in the IBM Developer's Toolkit for OS/2 2.0. The details of programming for the DRM_OS2FILE mechanism will therefore not be described further in this document.
Certain fields in the DRAGITEM structure are designed specifically for this rendering mechanism; the hstrContainer, hstrSourceName and hstrTargetName fields are ideally suited to holding the source directory name, source file name, and fully qualified target file name respectively. This is how these fields are used by the DRM_OS2FILE rendering mechanism.
An alternative, and even more straightforward way to implement this rendering mechanism, is to use the DrgDragFiles() function. This function automatically allocates and fills the required data structures for the source window, avoiding the need for the application to perform these functions and reducing the risk of error.