When an object is dragged over another object, the system invokes wpDragOver in the object being dragged over. This method receives a DRAGINFO structure, which contains pointers to DRAGITEM structures and other information. The potential target object examines this information to determine the validity of a Drop operation, and if the drop is not valid, changes the pointing device to indicate a "do not drop" situation. The following sample code shows an example of how to use wpDragOver:

/*
 *  Rejects objects that are not file system objects from being dropped
 *  on the Browse_O_matic.
 */

SOM_Scope MRESULT SOMLINK Browse_O_Maticwps_wpDragOver(
                          Browse_O_Matic *somSelf,
                          HWND hwndCnr,
                          PDRAGINFO pdrgInfo)
{
  MRESULT mResult;
  ULONG   ulCount;
  ULONG   ulNumberOfObjects;

  /* Browse_O_MaticData *somThis = Browse_O_MaticGetData(somSelf); */
  Browse_O_MaticMethodDebug("Browse_O_Matic",
                            "Browse_O_Maticwps_wpDragOver");

  /* Don't call the parent. Initialize mResult to allow */
  /* the drag over to proceed                           */
  mResult = MRFROM2SHORT(DOR_DROP, DO_MOVE);

  /* Determine the number of objects dragged */
  /* over the Browse-O-Matic                 */
  ulNumberOfObjects = DrgQueryDragitemCount( pdrgInfo);

  /* Check all the objects */
  for (ulCount=0; ulCount < ulNumberOfObjects &&
                            SHORT1FROMMR(mResult) !=
                                         DOR_NEVERDROP; ulCount++)

  {
    /* It must be a file system type object */
    if(DrgVerifyRMF(DrgQueryDragitemPtr(pdrgInfo, ulCount),
                   "DRM_OS2FILE",
                    NULL))
      mResult = MRFROM2SHORT(DOR_DROP, SHORT2FROMMR(mResult));
    else
      mResult = MRFROM2SHORT(DOR_NEVERDROP, SHORT2FROMMR(mResult));
  }
  return(mResult);
}


[Back] [Next]