Jump to content

DrgLazyDrag: Difference between revisions

From EDM2
Created page with "DrgLazyDrag is called when a direct-manipulation button is pressed while the lazy drag augmentation key is held to initiate a pickup and drop (lazy drag) operation. ==Syntax== DrgLazyDrag(hwndSource, pdinfo, pdimg, cdimg, pRsvd) ==Parameters== ;hwndSource (HWND) - input: Handle of the source window that is calling this function. ;pdinfo (PDRAGINFO) - input: Pointer to the DRAGINFO structure which contains information about the objects being dragged. ;pdimg (PDRAGI..."
 
No edit summary
 
Line 30: Line 30:
* Initializing the DRAGITEM structures using [[DrgSetDragitem]].
* Initializing the DRAGITEM structures using [[DrgSetDragitem]].


Objects are added to the drag set whenever a WM_PICKUP message is received. The first time that message is received, the application must call DrgLazyDrag to begin the lazy drag operation. Each subsequent WM_PICKUP message that is received during the course of a lazy drag operation indicates that objects are to be added to the drag set. If objects are currently being dragged, the application must reallocate the DRAGINFO structure using [[DrgReallocDragInfo]]. [[DrgReallocDragInfo]] frees the current DRAGINFO and allocates a new one. The lazy drag operation can then continue by making another call to DrgLazyDrag.
Objects are added to the drag set whenever a WM_PICKUP message is received. The first time that message is received, the application must call DrgLazyDrag to begin the lazy drag operation. Each subsequent WM_PICKUP message that is received during the course of a lazy drag operation indicates that objects are to be added to the drag set. If objects are currently being dragged, the application must reallocate the DRAGINFO structure using [[DrgReallocDraginfo]]. [[DrgReallocDraginfo]] frees the current DRAGINFO and allocates a new one. The lazy drag operation can then continue by making another call to DrgLazyDrag.


Objects can also be removed from the drag set during the course of a lazy drag operation. It is the application's responsibility to define what action initiates such a "putback" operation; for example, if a "pickup" operation executed while the pointer is not over a valid object. It is the application's responsibility to decide if a putback operation may apply to individual objects within the drag set or the drag set as a whole. If the putback operation is applied to the drag set as a whole, the result is the same as canceling the drag. If the put-back operation is applied to individual objects within the drag set, the application must free the DRAGINFO and reallocate it to represent the new state of the drag set. If the drag operation is to continue, the application must make another call to DrgLazyDrag.
Objects can also be removed from the drag set during the course of a lazy drag operation. It is the application's responsibility to define what action initiates such a "putback" operation; for example, if a "pickup" operation executed while the pointer is not over a valid object. It is the application's responsibility to decide if a putback operation may apply to individual objects within the drag set or the drag set as a whole. If the putback operation is applied to the drag set as a whole, the result is the same as canceling the drag. If the put-back operation is applied to individual objects within the drag set, the application must free the DRAGINFO and reallocate it to represent the new state of the drag set. If the drag operation is to continue, the application must make another call to DrgLazyDrag.

Latest revision as of 05:19, 8 April 2025

DrgLazyDrag is called when a direct-manipulation button is pressed while the lazy drag augmentation key is held to initiate a pickup and drop (lazy drag) operation.

Syntax

DrgLazyDrag(hwndSource, pdinfo, pdimg, cdimg, pRsvd)

Parameters

hwndSource (HWND) - input
Handle of the source window that is calling this function.
pdinfo (PDRAGINFO) - input
Pointer to the DRAGINFO structure which contains information about the objects being dragged.
pdimg (PDRAGIMAGE) - input
Pointer to an array of DRAGIMAGE structures.
These structures describe the images that are to be drawn under the direct-manipulation pointer during the drag.
cdimg (ULONG) - input
Number of DRAGIMAGE structures in the pdimg array.
pRsvd (PVOID) - input
Reserved value, must be 0.

Returns

rc (BOOL) - returns
Success indicator.
TRUE - A lazy drag operation was successfully started.
FALSE - An error occurred while initiating a lazy drag operation.

Remarks

Before initiating a lazy drag operation by calling DrgLazyDrag, the application must allocate the DRAGINFO structure using DrgAllocDraginfo.

DrgLazyDrag is called when the direct-manipulation button is pressed while holding down the lazy drag augmentation key, currently the ALT key. As the pointer moves over a potential target, a DM_DRAGOVER message is sent to the target window. When the pointer moves from one target window to another, a DM_DRAGLEAVE message is sent to the former target.

If the pointer is over a valid window target when the direct-manipulation button is pressed and the lazy drag "end drag" augmentation key (Ctrl+Shift to link, Ctrl to copy and Shift to move) is pressed, a DM_DROP message is sent to the target window. The source window posts a DM_DROPNOTIFY message, informing the target window that a drop has occurred.param2 parameter of DM_DROPNOTIFY message contains the handle of the target window that the drag set was dropped on. If param2 is zero, the drag set was not dropped; in other words, the drag operation was canceled. The source window must check pDraginfo to see if the target window is different from the source. If the source and target are different, the source window must free DRAGINFO upon receipt of the DM_DROPNOTIFY message. If the source and target window handles are the same, the target must free the DRAGINFO after completing the post-drop conversation.

The caller can define a default operation for the objects represented by the DRAGINFO structure by modifying its usOperate field. If usOperate is modified, the new value is sent to the target as the operation when a NO_DEFAULT operation would normally be sent. The caller must not modify any other part of the DRAGINFO structure. The DRAGITEM structures associated with the DRAGINFO structure must only be altered with DrgSetDragitem or by using a pointer obtained from DrgQueryDragitemPtr.

A window receives a WM_PICKUP message when the direct-manipulation button is pressed holding down the lazy drag augmentation key. In response to this message, an application is responsible for:

Objects are added to the drag set whenever a WM_PICKUP message is received. The first time that message is received, the application must call DrgLazyDrag to begin the lazy drag operation. Each subsequent WM_PICKUP message that is received during the course of a lazy drag operation indicates that objects are to be added to the drag set. If objects are currently being dragged, the application must reallocate the DRAGINFO structure using DrgReallocDraginfo. DrgReallocDraginfo frees the current DRAGINFO and allocates a new one. The lazy drag operation can then continue by making another call to DrgLazyDrag.

Objects can also be removed from the drag set during the course of a lazy drag operation. It is the application's responsibility to define what action initiates such a "putback" operation; for example, if a "pickup" operation executed while the pointer is not over a valid object. It is the application's responsibility to decide if a putback operation may apply to individual objects within the drag set or the drag set as a whole. If the putback operation is applied to the drag set as a whole, the result is the same as canceling the drag. If the put-back operation is applied to individual objects within the drag set, the application must free the DRAGINFO and reallocate it to represent the new state of the drag set. If the drag operation is to continue, the application must make another call to DrgLazyDrag.

DrgLazyDrag returns as soon as it completes initialization for the drag. The pointing device remains active during a lazy drag and can be used in the same manner as if no drag operation were in progress. As soon as DrgLazyDrag returns, the application can free its DRAGIMAGE array.

Note: Because the lazy drag operation is nonmodal, the mouse pointer may by used as if no drag operation were in progress.

Once a standard drag operation is commenced by calling DrgDrag, the objects that comprise the drag set cannot be modified without canceling the drag and restarting. The drag set can be modified during the course of the drag operation. When the drag set is modified, the application must reallocate the DRAGINFO structure and make another call to DrgLazyDrag.

Note: The mouse changes to an arrow with an attache case attached to the lower right-hand corner when the lazy drag is in progress, rather than a stack of images shown during a standard drag.

The pdimg and cdimg parameters were added for compatibility with DrgDrag only.

Example Code

#define INCL_WINSTDDRAG
#include <os2.h>

PDRAGINFO pdinfo;    /* Pointer to a DRAGINFO structure */
HWND      hwndSource; /* Handle of the Source window      */
DRAGITEM  ditem;      /* DRAGITEM structure             */
PDRAGIMAGE pdimg;     /* Pointer to DRAGIMAGE structure   */
HBITMAP   hbm;        /* Bit-map handle passed to DrgLazyDrag */
.
.
.
case WM_PICKUP:
/*******************************************************************/
/* Initialize the DRAGITEM structure                              */
/*******************************************************************/
ditem.hwndItem          = hwndSource;                 /* Handle of the source window */
ditem.ulItemID          = ID_ITEM;                    /* App defined id of item     */
ditem.hstrType          = DrgAddStrHandle("DRT_TEXT"); /* Text item                 */
ditem.hstrRMF           = DrgAddStrHandle("<DRM_OS2FILE,DRF_TEXT>");
ditem.hstrContainerName = DrgAddStrHandle("C:\\");
ditem.hstrSourceName    = DrgAddStrHandle("C:\\CONFIG.SYS");
ditem.hstrTargetName    = DrgAddStrHandle("C:\\OS2\\CONFIG.SYS");
ditem.cxOffset          = 0;                          /* X-offset of the origin of the image from the */
                                                    /* pointer hotspot            */
ditem.cyOffset          = 0;                          /* Y-offset of the origin of the image from the */
                                                    /* pointer hotspot            */
ditem.fsControl         = 0;                          /* Source item control flags  */
ditem.fsSupportedOps    = 0;
/*******************************************************************/
/* Create the DRAGINFO structure                                  */
/*******************************************************************/
pdinfo = DrgAllocDraginfo(1);
if(!pdinfo) return FALSE; /* Return FALSE if initialization fails */
/*******************************************************************/
/* Initialize the DRAGIMAGE structure                              */
/*******************************************************************/
pdimg=AllocMem(sizeof(DRAGIMAGE));
pdimg->cb            = sizeof(DRAGIMAGE); /* Size of the dragimage structure */
pdimg->cptl          = 0;                 /* Image is not a polygon          */
pdimg->hImage        = hbm;               /* Handle of image to display      */
pdimg->sizlStretch.cx = 20L;              /* Size to stretch icon or bit map */
pdimg->fl            = DRG_BITMAP|DRG_STRETCH; /* Flags passed to DrgLazyDrag     */
pdimg->cxOffset      = 0;                 /* Offset of the origin of image   */
pdimg->cyOffset      = 0;                 /* from the pointer hotspot        */
/*******************************************************************/
/* Set the DRAGITEM                                              */
/*******************************************************************/
DrgSetDragitem(pdinfo, &ditem, (ULONG)sizeof(ditem), 0);
/*******************************************************************/
/* Begin the Lazy Drag operation                                   */
/*******************************************************************/
if (DrgLazyDrag (hwndSource, /* Source of the drag      */
                 pdinfo,     /* Pointer to the DRAGINFO */
                 pdimg,      /* DRAGIMAGE array         */
                 1,          /* Size of the DRAGIMAGE array */
                 NULL)) {   /* Reserved                */
   FreeMem (pdimg);        /* Free DRAGIMAGE if successful */
}

Related Functions