Jump to content

DrgReallocDraginfo

From EDM2

This function releases the current DRAGINFO structure and reallocates a new one.

Syntax

DrgReallocDragInfo(pdinfoOld, cditem)

Parameters

pdinfoOld (PDRAGINFO) - input
Pointer to the current DRAGINFO structure.
cditem (ULONG) - input
Number of DRAGITEM structures to be allocated.

Returns

pdinfoCurrent (PDRAGINFO) - returns
Pointer to a newly allocated DRAGINFO structure.

Remarks

It is necessary to call DrgReallocDragInfo anytime objects are added or deleted from the current lazy drag set. This function unconditionally frees the old DRAGINFO structure, reallocates a new DRAGINFO structure, and returns a pointer to the new structure.

Note: This function does not check if the source and target window handles are different; it unconditionally frees the DRAGINFO structure passed to it.

Example Code

This example uses DrgReallocDragInfo to reallocate the DRAGINFO structure when an object is picked up or added to the lazy drag set. It checks whether a lazy drag operation is already in progress, and if so, adds one to the number of objects currently being dragged and calls DrgReallocDragInfo to obtain a new DRAGINFO structure with the required number of DRAGITEM structures.

#define INCL_WINSTDDRAG
#include <os2.h>

PDRAGINFO pdinfoCurrent; /* Pointer to the current DRAGINFO */
PDRAGINFO pdinfoOld;     /* Pointer to the DRAGINFO to be freed */
ULONG     cditem;        /* Number of DRAGITEMS                 */
.
.
.
case WM_PICKUP:
   if (DrgQueryDragStatus() & DGS_LAZYDRAGINPROGRESS)
   {
      /* Get a pinter to the current DRAGINFO structure */
      pdinfoOld=DrgQueryDraginfoPtr(NULL);
      /* Add space for one more DRAGITEM */
      cditem=pdinfoOld->cditem+1;
      /* Reallocate the DRAGINFO */
      pdinfoCurrent=DrgReallocDraginfo(pdinfoOld, cditem);
      if(pdinfoCurrent)
      {
         /* Continue the lazy drag operation */
         DrgLazyDrag( ... )
      }
   }

Related Functions