Jump to content

wpDrop

From EDM2
Revision as of 22:35, 16 November 2025 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This instance method is called to inform an object that another object has been dropped on it.

Syntax

_wpDrop(somSelf, hwndCnr, pdrgInfo, pdrgItem)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
hwndCnr (HWND) - input
Handle to the container control window.
pdrgInfo (PDRAGINFO) - input
Pointer to a DRAGINFO structure. This parameter is used to access all the objects in the drop set, if multiple objects are being dropped.
pdrgItem (PDRAGITEM) - input
Pointer to a DRAGITEM structure. This is the object that is currently being dropped.

Returns

rc (MRESULT) - returns
Return code.
  • RC_DROP_DROPCOMPLETE All objects in the drag set have been dropped successfully. **wpDrop** is not called for the next item in the drop set, and *pdrgInfo* is not freed.
  • RC_DROP_ERROR An error occurred while processing the drop operation. The drop operation is terminated, **wpDrop** is not called for the next item in the drop set, and *pdrgInfo* is freed.
  • RC_DROP_ITEMCOMPLETE One object in the drag set, specified by *pdrgItem*, has been dropped successfully. *pdrgInfo* is freed after all objects in the drop set have been dropped.
  • RC_DROP_RENDERING The object being dropped has asked for a rendering of the source object. **wpDrop** is called for the next item in the drop set, *pdrgInfo* is freed after all objects in the drop set have been dropped.

How to Override

This method should be overridden to process the action of the dragged object or objects being dropped on it.

Usage

This method is generally called only by the system as a folder containing the object processes the `DM_DROP` message.

Remarks

The **wpDrop** method is called when a `DM_DROP` message is received by the object. See `DM_DROP` in the *Presentation Manager Programming Reference* for more information.

Related Methods

Example Code

Definition.

#define INCL_WINWORKPLACE
#include <os2.h>

WPObject *somSelf; /* Pointer to the object on which the method is being invoked. */
HWND hwndCnr; /* Handle to the container control window. */
PDRAGINFO *pdrgInfo; /* Pointer to a DRAGINFO structure. */
PDRAGITEM *pdrgItem; /* Pointer to a DRAGITEM structure. */
MRESULT rc; /* Return code. */

rc = _wpDrop(somSelf, hwndCnr, pdrgInfo, pdrgItem);

In this example, objects that are not file system objects are prevented from being dropped on the Browse_O_matic.

SOM_Scope MRESULT SOMLINK Browse_O_Maticwps_wpDrop(Browse_O_Matic *somSelf,
                HWND hwndCnr,
                PDRAGINFO pdrgInfo,
                PDRAGITEM pdrgItem)
{
    CHAR pszBuffer[ 255 ];
    MRESULT mResult;

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

    mResult = MRFROM2SHORT( DOR_DROP, 0);

    /***************************************************************/
    /* Don't call the parent. Initialize mResult to allow the drop */
    /* to proceed.                                                 */
    /***************************************************************/
    if( DOR_NEVERDROP != SHORT1FROMMR( mResult) &&
                                  DrgVerifyRMF( pdrgItem, "DRM_OS2FILE", NULL)){

        /* Get the path */
        DrgQueryStrName( pdrgItem->hstrContainerName, sizeof( pszBuffer),
                                                         pszBuffer);

        /* Append the name of the object to the path */
        DrgQueryStrName( pdrgItem->hstrSourceName,
                                         sizeof( pszBuffer) - strlen( pszBuffer),
                                         &pszBuffer[ strlen( pszBuffer)]);
        _wpViewObject( somSelf, NULLHANDLE, OPEN_DEFAULT, (ULONG)pszBuffer);

        mResult = MRFROM2SHORT( DOR_DROP, SHORT2FROMMR( mResult));
    }
    else
        mResult = MRFROMSHORT( DOR_NEVERDROP );

    return( mResult );
}