Jump to content

wpDragOver

From EDM2
Revision as of 06:32, 16 November 2025 by Martini (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This instance method is called to inform the object that other objects are being dragged over it.

Syntax

_wpDragOver(somSelf, hwndCnr, pdrgInfo)

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 drag information.

Returns

rc (MRESULT) - returns
Return code.
See `DM_DRAGOVER` in the *Presentation Manager Programming Reference* for description of the return value.

How to Override

This method should be overridden to determine if the object or objects being dragged can be dropped on this object.

Usage

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

Example Code

#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 drag information. */
MRESULT rc; /* Return code. */

rc = _wpDragOver(somSelf, hwndCnr, pdrgInfo);

Remarks

The **wpDragOver** method is sent for each `DM_DRAGOVER` message received by the object. See `DM_DRAGOVER` in the *Presentation Manager Programming Reference* for more information.

Related Methods

Example Code

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_wpDragOver(Browse_O_Matic *somSelf,
                HWND hwndCnr,
                PDRAGINFO pdrgInfo)
{
    MRESULT mResult;
    ULONG ulCount;
    ULONG ulNumberOfObjects;

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

    /********************************************************************/
    /* Don't call the parent. Initialize mResult to allow the drag over */
    /* to proceed.                                                      */
    /********************************************************************/
    mResult = MRFROM2SHORT( DOR_DROP, DO_MOVE);

    /*******************************************************************/
    /* Determine the number of objects dragged over the Browse-O-Matic */
    /*******************************************************************/
    ulNumberOfObjects = DrgQueryDragitemCount( pdrgInfo);

    /*************************/
    /* Check all the objects */
    /*************************/
    for( ulCount=0; ulCount < ulNumberOfObjects &&
                             SHORT1FROMMR( mResult) != DOR_NEVERDROP; ulCount++){

        /*****************************************/
        /* It must be a file system type object. */
        /*****************************************/
        if( DrgVerifyRMF( DrgQueryDragitemPtr( pdrgInfo, ulCount),
                                              "DRM_OS2FILE", NULL))
            mResult = MRFROM2SHORT( DOR_DROP, SHORT2FROMMR( mResult));
        else
            mResult = MRFROM2SHORT( DOR_NEVERDROP, SHORT2FROMMR( mResult));
    }

    return( mResult);
}