home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / wpshidl / samples / wpsamps / dragfold.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-18  |  4.5 KB  |  140 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 2.7
  6.  */
  7.  
  8. /******************************************************************************
  9. *
  10. *  Module Name: DRAGFOLD.C
  11. *
  12. *  OS/2 Work Place Shell IDL File BETA Sample Program
  13. *
  14. *  Copyright (C) 1993 IBM Corporation
  15. *
  16. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  17. *      sample code created by IBM Corporation. This sample code is not
  18. *      part of any standard or IBM product and is provided to you solely
  19. *      for  the purpose of assisting you in the development of your
  20. *      applications.  The code is provided "AS IS", without
  21. *      warranty of any kind.  IBM shall not be liable for any damages
  22. *      arising out of your use of the sample code, even if they have been
  23. *      advised of the possibility of such damages.                                                    *
  24. *
  25. ******************************************************************************/
  26.  
  27.  
  28. #define INCL_DOS
  29. #define INCL_PM
  30. #include <os2.h>
  31.  
  32. #define DRAGFOLD_Class_Source
  33. #include "dragfold.ih"
  34.  
  35.  
  36. /*
  37.  * SOM_Scope MRESULT   SOMLINK dragf_wpDragOver(DRAGFOLD *somSelf,
  38.  *                 HWND hwndCnr,
  39.  *                 PDRAGINFO pdrgInfo)
  40.  *
  41.  * When an object is dragged over an object of class DRAGFOLD, it will
  42.  * go through the DRAGINFO structure and check to see if the DRAGITEMs
  43.  * indicate the special RMF for the DRAGEXAM class, if so, then we will
  44.  * indicate that we will accept the drop
  45.  */
  46.  
  47. SOM_Scope MRESULT  SOMLINK dragf_wpDragOver(DRAGFOLD *somSelf,
  48.                                             HWND hwndCnr, PDRAGINFO pdrgInfo)
  49. {
  50.     MRESULT   mr;
  51.     PDRAGITEM pDragItem;
  52.     ULONG     i;
  53.     ULONG     ulOurs = 0;
  54.  
  55.     /* DRAGFOLDData *somThis = DRAGFOLDGetData(somSelf); */
  56.     DRAGFOLDMethodDebug("DRAGFOLD","dragf_wpDragOver");
  57.  
  58.     /* go through all the dragitems one by one */
  59.     for (i = 0; i < pdrgInfo->cditem ; i++)
  60.     {
  61.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  62.  
  63.        /* if this dragitem indicates the special RMF, then keep a count */
  64.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  65.        {
  66.           ulOurs++;
  67.        }
  68.     }
  69.  
  70.     /* if after processing all the dragitems in the draginfo structure,
  71.      * accept the drop based on the following criteria:
  72.      */
  73.     if (ulOurs == 0)
  74.     {
  75.        /* if none used the special RMF, just pass it on through */
  76.        mr = (parent_wpDragOver(somSelf,hwndCnr,pdrgInfo));
  77.     }
  78.     else
  79.     {
  80.        /* if they ALL used the special RMF, then indicate that a drop
  81.         * is ok
  82.         */
  83.        if (ulOurs == pdrgInfo->cditem)
  84.        {
  85.           mr = MRFROM2SHORT(DOR_DROP,
  86.                            (SHORT)((pdrgInfo->usOperation == DO_DEFAULT)
  87.                                    ? DO_MOVE : pdrgInfo->usOperation));
  88.        }
  89.        else
  90.        {
  91.           /* otherwise, we don't know quite how to handle a mixture
  92.            * of items, so we'll just say they can't be dropped
  93.            */
  94.           mr = MRFROM2SHORT(DOR_NEVERDROP,DO_DEFAULT);
  95.        }
  96.     }
  97.     return mr;
  98. }
  99.  
  100.  
  101. /*
  102.  * SOM_Scope MRESULT   SOMLINK dragf_wpDrop(DRAGFOLD *somSelf,
  103.  *                 HWND hwndCnr,
  104.  *                 PDRAGINFO pdrgInfo,
  105.  *                 PDRAGITEM pdrgItem)
  106.  *
  107.  * If a drop does occur, we want to make sure that the special
  108.  * RMF is removed from the dragitem(s) and replaced with one the
  109.  * parent will understand, and we'll let them actually handle the
  110.  * drop.
  111.  */
  112.  
  113. SOM_Scope MRESULT  SOMLINK dragf_wpDrop(DRAGFOLD *somSelf, HWND hwndCnr,
  114.                                         PDRAGINFO pdrgInfo, PDRAGITEM pdrgItem)
  115. {
  116.     ULONG     i;
  117.     PDRAGITEM pDragItem;
  118.  
  119.     /* DRAGFOLDData *somThis = DRAGFOLDGetData(somSelf); */
  120.     DRAGFOLDMethodDebug("DRAGFOLD","dragf_wpDrop");
  121.  
  122.     /* look at each dragitem */
  123.     for (i = 0; i < pdrgInfo->cditem ; i++)
  124.     {
  125.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  126.  
  127.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  128.        {
  129.           /* change the RMF to something the WPSH classes understand */
  130.           DrgDeleteStrHandle(pDragItem->hstrRMF);
  131.           pDragItem->hstrRMF = DrgAddStrHandle("<DRM_OBJECT,DRF_OBJECT>");
  132.        }
  133.     }
  134.  
  135.     /* let the parent handle drop processing since we've already
  136.      * arbitrated who was allowed to be dropped in wpDragOver
  137.      */
  138.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  139. }
  140.