Jump to content

wpDraggedOverObject

From EDM2

This instance method may be called on an object that is currently being dragged with the mouse to identify the current target object. The return code from this method lets the system know whether the object being dragged can be dropped on the specified target.

Syntax

_wpDraggedOverObject(somSelf, DraggedOverObject)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
DraggedOverObject (WPObject *) - input
Pointer to the object that the drag cursor is over.
The current target object for the drag operation.
Points to an object of class WPObject.

Returns

rc (MRESULT) - returns
Return code.
  • DropIndicator (USHORT) Low-word.
This code is one of the **DOR_\*** constants, such as **DOR_DROP** or **DOR_NODROP**, which indicate whether a drop is allowed on the current target.
  • DropOperation (USHORT) High-word.
The current drag operation code. Examples are **DO_COPY**, **DO_MOVE** or **DO_LINK** to indicate that the drag action over this target should be a copy, move, or a link.

How to Override

Override this method if your object class wishes to allow itself to be used as a source object that can perform a drop operation. A favorable return code from this method may lead to a wpDroppedOnObject instance method being invoked on the source object. The instance method would be overridden to actually do the drop operation.

Usage

This method is typically called by objects that require participation from the source object when a drop occurs. The method can be called at any time; however, the method would normally be called only by a target object on one of the source objects during a drag or drop operation.

Example Code

#define INCL_WINWORKPLACE
#include <os2.h>

WPObject *somSelf; /* Pointer to the object on which the method is being invoked. */
WPObject *DraggedOverObject; /* Pointer to the object that the drag cursor is over. */
MRESULT rc; /* Return code. */

rc = _wpDraggedOverObject(somSelf, DraggedOverObject);

Remarks

When a target object is dragged over by the mouse, it will always receive a wpDragOver instance method call. Many target objects will choose to decide the current drag operation and whether a drop is possible based upon their own rules. For instance, the WPShredder object will return **DO_DROP,DO_MOVE** if it decides that all the source objects can be deleted. However, some targets require the source or sources to participate in the decision over whether they can accept the drop. The way that a target allows a source object to have a say in what the drop action will be is by calling the **wpDraggedOverObject** on each source object. The **wpDraggedOverObject** instance method may be invoked, on an object that is being dragged (source object) at any time, to see if it can support a drop on the current target. If the object that is being dragged responds favorably to this method, it may later receive a wpDroppedOnObject instance method call so that it can process the drop action.

As an example, consider the case where a program object is dragged onto a data file object. The program would respond **DO_DROP** to the **wpDraggedOverObject** instance method, so that the data file would be a valid drop target. If the user chose to allow the drop, then the program would receive a wpDroppedOnObject instance method. Then the program would be able to open itself as a viewer of the data file object.

This method is called as a result of a `DM_DRAGOVER` message being sent. For further documentation of the possible return values, see `DM_DRAGOVER` in the *Presentation Manager Programming Reference*.

Related Methods