Jump to content

wpDelete

From EDM2

This instance method is called to delete an object and prompt for confirmation if necessary.

Syntax

_wpDelete(somSelf, fConfirmations)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
fConfirmations (ULONG) - input
Confirmation flags.
CONFIRM_DELETE Prompt for confirmation for all objects.
CONFIRM_DELETEFOLDER Prompt for confirmation for folder objects, only.
NULL No confirmations.

Returns

rc (ULONG) - returns
Success indicator.
NO_DELETE Error occurred.
CANCEL_DELETE User canceled the operation.
OK_DELETE Object was deleted.

Remarks

The confirmation flags are passed to the wpConfirmDelete method. If wpConfirmDelete returns OK_DELETE, the wpFree method is called on the object.

Usage

This method can be called at any time in order to delete an object.

How to Override

This method is generally not overridden.

Example Code

This example performs special processing upon opening a folder.

SOM_Scope HWND   SOMLINK myfold_wpOpen(MYFOLDER *somSelf,
                 HWND hwndCnr,
                 ULONG ulView,
                 ULONG param)

{
    HWND       hwndFromParentOpen = NULLHANDLE;
    MYFOLDERData *somThis = MYFOLDERGetData(somSelf);
    MYFOLDERMethodDebug("MYFOLDER","myfold_wpOpen");

    if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
    {
               /* ONLY do this on FIRST open of the folder. */

       if (_wpPopulate(somSelf, NULLHANDLE, NULL, FALSE))
       {
           WPObject *Obj;
           WPObject *LastFoundObj = NULL;

           /* Check contents of folder and see which are instances of
            * WPFolder, we'll delete any WPFolders as a cleanup step */

           for ( Obj = _wpQueryContent(somSelf,NULL,(ULONG)QC_First);
                 Obj;
                 Obj = _wpQueryContent(somSelf, Obj, (ULONG) QC_Next ))

           {
             /* delete the last object found on the previous iteration
              * of the loop (we couldn't delete it then, because we
              * needed it at the top of the loop for this iteration)
              */
             if (LastFoundObj) {
                 _wpDelete(LastFoundObj,0);
                 LastFoundObj = NULL;
              } /* endif */

              /* we want to make sure that all previously
               * existing folders are deleted */

              if (_somIsA(Obj, _WPFolder)) {
                  LastFoundObj = Obj;
              }  /* endif */

           }  /* endfor */

           /* if there is still one object left to delete, do it now */


           if (LastFoundObj) {
              _wpDelete(LastFoundObj,0);
              LastFoundObj = NULL;
           } /* endif */
       } /* end if populate */
    } /* end if first open */

               /* Show the opened folder */

    hwndFromParentOpen = parent_wpOpen(somSelf, hwndCnr, ulView, param);

                /* If this is the first open, set our global flag */

    if (_queryFirstViewHandle(somSelf) == NULLHANDLE)  {
        _setFirstViewHandle(somSelf, hwndFromParentOpen);
    } /* endif */

    return( hwndFromParentOpen );
}

Related Methods