home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
BLACKH.ZIP
/
BlackHol.c
next >
Wrap
Text File
|
1992-11-19
|
6KB
|
160 lines
/*
* This file was generated by the SOM Compiler.
* FileName: BlackHol.c.
* Generated using:
* SOM Precompiler spc: 1.22
* SOM Emitter emitc: 1.24
*/
/*────────────────────────────────────────────────────────────────────┐
│ Greg's Black Hole - anything you put in will disappear forever... │
│ │
└──────────────────┐ Gregory Czaja, CONT00 @ LEXVMK, November 1992 │
└─────────────────────────────────────────────────*/
#define BlackHole_Class_Source
#include "BlackHol.ih"
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
void MyFreeDraginfo(PDRAGINFO pdrgInfo);
SOM_Scope MRESULT SOMLINK BlackHolX_wpDragOver(BlackHole *somSelf,
HWND hwndCnr,
PDRAGINFO pdrgInfo)
{
ULONG ulItemCnt=0;
ULONG ulItem=0;
USHORT usDropIndic=DOR_DROP;
BlackHoleData *somThis = BlackHoleGetData(somSelf);
BlackHoleMethodDebug("BlackHole","BlackHolX_wpDragOver");
/* Check that items are workplace shell objects */
ulItemCnt=DrgQueryDragitemCount(pdrgInfo);
for(ulItem=0;ulItem<ulItemCnt;ulItem++) {
DRAGITEM DItem;
DrgQueryDragitem(pdrgInfo,sizeof(DItem),&DItem,ulItem);
/* check that it is a WPS object RMF */
if(!DrgVerifyRMF(&DItem,"DRM_OBJECT","DRF_OBJECT")) {
/* if it's not - don't accept ! */
usDropIndic=DOR_NEVERDROP;
}/* end if */
}/* end for */
/* Free the draginfo if not same process */
MyFreeDraginfo(pdrgInfo);
return (MRFROM2SHORT(usDropIndic,DO_UNKNOWN));
/*
return (parent_wpDragOver(somSelf,hwndCnr,pdrgInfo));
*/
}
SOM_Scope MRESULT SOMLINK BlackHolX_wpDrop(BlackHole *somSelf,
HWND hwndCnr,
PDRAGINFO pdrgInfo,
PDRAGITEM pdrgItem)
{
WPObject *pWPObjDropped;
PSZ message =malloc(256);
PSZ object;
PSZ class;
BlackHoleData *somThis = BlackHoleGetData(somSelf);
BlackHoleMethodDebug("BlackHole","BlackHolX_wpDrop");
pWPObjDropped=OBJECT_FROM_PREC(pdrgItem->ulItemID);
object =_wpQueryTitle(pWPObjDropped);
class =(PSZ)_somGetClassName(pWPObjDropped);
strcpy(message, "You are about to delete: ");
strcat(message, object);
strcat(message, ". Push \"Yes\" to confirm, \"No\" to cancel !");
if (MBID_YES == WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
message,
"Black Hole - destroy object",
0,
MB_YESNO | MB_DEFBUTTON2 | MB_WARNING | MB_SYSTEMMODAL )){
/* wants a VERY special delete ??? */
if (strcmp(class, "WPDesktop") == 0) {
WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
"You must be joking...",
"Black Hole - destroy object",
0,
MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL );
} else {
_wpSetStyle(pWPObjDropped, !OBJSTYLE_NODELETE);
if ( _wpDelete(pWPObjDropped, 0) != OK_DELETE ) {
strcpy(message, "Object: ");
strcat(message, object);
strcat(message, " could not be deleted !");
WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
message,
"Black Hole - destroy object",
0,
MB_CANCEL | MB_WARNING | MB_SYSTEMMODAL );
};
} /* endif */
};
free(message);
return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
}
#undef SOM_CurrentClass
#define SOM_CurrentClass SOMMeta
SOM_Scope void SOMLINK BlackHolC_wpclsInitData(M_BlackHole *somSelf)
{
/* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */
M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsInitData");
parent_wpclsInitData(somSelf);
}
SOM_Scope void SOMLINK BlackHolC_wpclsUnInitData(M_BlackHole *somSelf)
{
/* M_BlackHoleData *somThis = M_BlackHoleGetData(somSelf); */
M_BlackHoleMethodDebug("M_BlackHole","BlackHolC_wpclsUnInitData");
parent_wpclsUnInitData(somSelf);
}
/*───────────────────────── ORDINARY CODE SECTION ──────────────────────────┐
│**** ****│
│**** Any non-method code should go here. ****│
│**** ****│
└────────────────────────────────────────────────────────────────────────────*/
#undef SOM_CurrentClass
/*──────────────────────────────────────────────────────────────────────────┐
│ MyFreeDraginfo() courtesy of Ph. Gregoire │
│ Purpose: Frees the drag info if not same process │
└──────────────────────────────────────────────────────────────────────────*/
void MyFreeDraginfo(PDRAGINFO pdrgInfo)
{PID pidSrc;
TID tidSrc;
PTIB ptib;
PPIB ppib;
WinQueryWindowProcess(pdrgInfo->hwndSource,&pidSrc,&tidSrc);
DosGetInfoBlocks(&ptib,&ppib);
if(ppib->pib_ulpid!=pidSrc) {
DrgFreeDraginfo(pdrgInfo);
}/* end if */
}/* end MyFreeDraginfo */