home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / BLACKH.ZIP / BlackHol.c next >
Text File  |  1992-11-19  |  6KB  |  160 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: BlackHol.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.24
  8.  */
  9.  
  10. /*────────────────────────────────────────────────────────────────────┐
  11. │  Greg's Black Hole - anything you put in will disappear forever...  │
  12. │                                                                     │
  13. └──────────────────┐   Gregory Czaja, CONT00 @ LEXVMK, November 1992  │
  14.                    └─────────────────────────────────────────────────*/
  15.  
  16.  
  17. #define BlackHole_Class_Source
  18. #include "BlackHol.ih"
  19.  
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <malloc.h>
  23.  
  24. void MyFreeDraginfo(PDRAGINFO pdrgInfo);
  25.  
  26. SOM_Scope MRESULT   SOMLINK BlackHolX_wpDragOver(BlackHole *somSelf,
  27.                 HWND hwndCnr,
  28.                 PDRAGINFO pdrgInfo)
  29. {
  30.     ULONG ulItemCnt=0;
  31.     ULONG ulItem=0;
  32.     USHORT usDropIndic=DOR_DROP;
  33.     BlackHoleData *somThis = BlackHoleGetData(somSelf);
  34.     BlackHoleMethodDebug("BlackHole","BlackHolX_wpDragOver");
  35.  
  36.           /* Check that items are workplace shell objects */
  37.  
  38.       ulItemCnt=DrgQueryDragitemCount(pdrgInfo);
  39.       for(ulItem=0;ulItem<ulItemCnt;ulItem++) {
  40.        DRAGITEM DItem;
  41.  
  42.         DrgQueryDragitem(pdrgInfo,sizeof(DItem),&DItem,ulItem);
  43.  
  44.                       /* check that it is a WPS object RMF */
  45.         if(!DrgVerifyRMF(&DItem,"DRM_OBJECT","DRF_OBJECT")) {
  46.                       /* if it's not - don't accept !      */
  47.           usDropIndic=DOR_NEVERDROP;
  48.         }/* end if */
  49.       }/* end for */
  50.  
  51.                     /* Free the draginfo if not same process */
  52.       MyFreeDraginfo(pdrgInfo);
  53.  
  54.       return (MRFROM2SHORT(usDropIndic,DO_UNKNOWN));
  55.       /*
  56.       return (parent_wpDragOver(somSelf,hwndCnr,pdrgInfo));
  57.        */
  58. }
  59.  
  60. SOM_Scope MRESULT   SOMLINK BlackHolX_wpDrop(BlackHole *somSelf,
  61.                 HWND hwndCnr,
  62.                 PDRAGINFO pdrgInfo,
  63.                 PDRAGITEM pdrgItem)
  64. {
  65.     WPObject *pWPObjDropped;
  66.     PSZ   message =malloc(256);
  67.     PSZ   object;
  68.     PSZ   class;
  69.  
  70.     BlackHoleData *somThis = BlackHoleGetData(somSelf);
  71.     BlackHoleMethodDebug("BlackHole","BlackHolX_wpDrop");
  72.  
  73.     pWPObjDropped=OBJECT_FROM_PREC(pdrgItem->ulItemID);
  74.     object  =_wpQueryTitle(pWPObjDropped);
  75.     class   =(PSZ)_somGetClassName(pWPObjDropped);
  76.  
  77.  
  78.     strcpy(message, "You are about to delete: ");
  79.     strcat(message, object);
  80.     strcat(message, ". Push \"Yes\" to confirm, \"No\" to cancel !");
  81.     if (MBID_YES == WinMessageBox(HWND_DESKTOP,
  82.                                   HWND_DESKTOP,
  83.                                   message,
  84.                                  "Black Hole - destroy object",
  85.                                   0,
  86.                                   MB_YESNO | MB_DEFBUTTON2 | MB_WARNING | MB_SYSTEMMODAL )){
  87.                                   /* wants a VERY special delete ??? */
  88.        if (strcmp(class, "WPDesktop") == 0) {
  89.           WinMessageBox(HWND_DESKTOP,
  90.                         HWND_DESKTOP,
  91.                         "You must be joking...",
  92.                         "Black Hole - destroy object",
  93.                         0,
  94.                         MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL );
  95.        } else {
  96.           _wpSetStyle(pWPObjDropped, !OBJSTYLE_NODELETE);
  97.           if ( _wpDelete(pWPObjDropped, 0) != OK_DELETE ) {
  98.              strcpy(message, "Object: ");
  99.              strcat(message, object);
  100.              strcat(message, " could not be deleted !");
  101.              WinMessageBox(HWND_DESKTOP,
  102.                            HWND_DESKTOP,
  103.                            message,
  104.                            "Black Hole - destroy object",
  105.                            0,
  106.                            MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL );
  107.           };
  108.        } /* endif */
  109.     };
  110.     free(message);
  111.  
  112.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  113. }
  114.  
  115. #undef SOM_CurrentClass
  116. #define SOM_CurrentClass SOMMeta
  117. SOM_Scope void   SOMLINK BlackHolC_wpclsInitData(M_BlackHole *somSelf)
  118. {
  119.     /* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */
  120.     M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsInitData");
  121.  
  122.     parent_wpclsInitData(somSelf);
  123. }
  124.  
  125. SOM_Scope void   SOMLINK BlackHolC_wpclsUnInitData(M_BlackHole *somSelf)
  126. {
  127.     /* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */
  128.     M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsUnInitData");
  129.  
  130.     parent_wpclsUnInitData(somSelf);
  131. }
  132.  
  133. /*─────────────────────────  ORDINARY CODE SECTION  ──────────────────────────┐
  134. │****                                                                     ****│
  135. │****                  Any non-method code should go here.                ****│
  136. │****                                                                     ****│
  137. └────────────────────────────────────────────────────────────────────────────*/
  138. #undef SOM_CurrentClass
  139.  
  140.  
  141. /*──────────────────────────────────────────────────────────────────────────┐
  142. │ MyFreeDraginfo()        courtesy of Ph. Gregoire                          │
  143. │ Purpose: Frees the drag info if not same process                          │
  144. └──────────────────────────────────────────────────────────────────────────*/
  145. void MyFreeDraginfo(PDRAGINFO pdrgInfo)
  146. {PID pidSrc;
  147.  TID tidSrc;
  148.  PTIB ptib;
  149.  PPIB ppib;
  150.  
  151.   WinQueryWindowProcess(pdrgInfo->hwndSource,&pidSrc,&tidSrc);
  152.   DosGetInfoBlocks(&ptib,&ppib);
  153.  
  154.   if(ppib->pib_ulpid!=pidSrc) {
  155.     DrgFreeDraginfo(pdrgInfo);
  156.   }/* end if */
  157.  
  158. }/* end MyFreeDraginfo */
  159.  
  160.