The following sample code shows a Pickup and Drop operation after the user has selected an object and pressed mouse button 2 while holding down the Pickup and Drop augmentation key (Alt):
#define INCL_WINSTDDRAG #include <os2.h>
PDRAGINFO pdinfo; /* Pointer to a DRAGINFO data structure */
HWND hwndSource; /* Handle of the Source window */
DRAGITEM ditem; /* DRAGITEM data structure */
PDRAGIMAGE pdimg; /* Pointer to DRAGIMAGE data structure */
HBITMAP hbm; /* Bit-map handle passed to DrgLazyDrag */
APIRET rc; /* Allocation memory return code */
case WM_PICKUP:
/***********************************************************************/
/* Initialize the DRAGITEM data 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; /* Offset of the origin of the image */
ditem.cyOffset = 0; /* from the pointer hotspot */
ditem.fsControl = 0; /* Source item control flags */
ditem.fsSupportedOps = 0;
/***********************************************************************/
/* Create the DRAGINFO data structures */
/***********************************************************************/
pdinfo=DrgAllocDraginfo(1);
/* Return FALSE if initialization fails */
if(!pdinfo) return FALSE;
/***********************************************************************/
/* Initialize the DRAGIMAGE data structure. */
/***********************************************************************/
rc=DosAllocMem((PPVOID)&pdimg, /* Allocate memory */
sizeof(DRAGIMAGE),
(ULONG)PAG_COMMIT |
PAG_READ |
PAG_WRITE);
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 | /* Flags passed to DrgLazyDrag */
DRG_STRETCH;
pdimg->cxOffset=0; /* Offset of the origin of image */
pdimg->cyOffset=0; /* from the pointer hotspot */
/***********************************************************************/
/* Set the DRAGITEM data structure. */
/***********************************************************************/
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 */
NULL)) /* Reserved */
{
DosFreeMem(pdimg); /* Free DRAGIMAGE if successful */
}