DrgLazyDrag - Example Code

This example shows the proper sequence for initiating a lazy drag operation after the user has selected an object and pressed the direct manipulation button while holding down the lazy drag augmentation key (ALT). The window receives a WM_PICKUP message indicating that a lazy drag operation is to begin.

#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 */
     }


[Back: DrgLazyDrag - Related Functions]
[Next: DrgLazyDrag - Topics]