Jump to content

DrgSendTransferMsg

From EDM2
Revision as of 05:06, 8 April 2025 by Iturbide (talk | contribs) (Created page with "This function sends a message to the other application involved in the direct manipulation operation. ==Syntax== DrgSendTransferMsg(hwndTo, ulMsgid, mpParam1, mpParam2) ==Parameters== ;hwndTo (HWND) - input: Window handle to which the message is to be sent. :: '''Target''': hwndItem in the DRAGITEM structure. :: '''Source''': hwndClient in the DRAGTRANSFER structure. ;ulMsgid (ULONG) - input: Identifier of the message to be sent. :: Valid messages are: ::: DM_...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function sends a message to the other application involved in the direct manipulation operation.

Syntax

DrgSendTransferMsg(hwndTo, ulMsgid, mpParam1, mpParam2)

Parameters

hwndTo (HWND) - input
Window handle to which the message is to be sent.
Target: hwndItem in the DRAGITEM structure.
Source: hwndClient in the DRAGTRANSFER structure.
ulMsgid (ULONG) - input
Identifier of the message to be sent.
Valid messages are:
DM_ENDCONVERSATION
DM_RENDER
DM_RENDERPREPARE
mpParam1 (MPARAM) - input
First message parameter.
mpParam2 (MPARAM) - input
Second message parameter.

Returns

mresReply (MRESULT) - returns
Message-return data.

Remarks

If the message to be sent is DM_RENDER or DM_RENDERCOMPLETE, the fsReply field in DRAGTRANSFER is set to 0 before the message is sent. If the message cannot be sent, FALSE is returned.

When the message to be sent is DM_RENDER, DosGiveSeg is called. DosGiveSeg gives access to the DRAGTRANSFER structure to the process that owns the window indicated by hwndTo. The use count for the segment in which the DRAGTRANSFER structure exists is incremented.

The process to which the message is being sent must call DrgFreeDragtransfer for the DRAGTRANSFER structure before the segment can be freed.

Example Code

This function is used to send a message from one window to another when a direct manipulation is in progress. In this example, the function is used to inform the target that the operation is complete and successful.

#define INCL_WINSTDDRAG /* Direct Manipulation (Drag) Functions */
#include <os2.h>

PDRAGINFO pdinfo;
MPARAM   mp1;
TID      tid;

case DM_DROP:
   pdinfo = (PDRAGINFO) mp1;
   /***************************************************************/
   /* If this is a copy operation, spawn a thread to do the copy */
   /***************************************************************/
   if (pdinfo->usOperation == DO_COPY)
   {
      DosCreateThread (&tid, CopyThread, pdinfo, FALSE, 4096);
   }
   break;

void Copy Thread (PDRAGINFO pdinfo)
{
   PDRAGITEM pditem;
   USHORT    i;
   ULONG     flResult;
   HAB       hab;
   HMQ       hmq;
   char      szSource[CCH_MAXPATH];
   char      szTarget[CCH_MACPATH];

   /***************************************************************/
   /* DrgSendTransferMsg needs a message queue, so create one for */
   /* this thread                                               */
   /***************************************************************/
   hab = WinInitialize (0);
   hmq = WinCreateMsgQueue (hab, 0);

   /***************************************************************/
   /* Try to copy each item that was dragged                     */
   /***************************************************************/
   for (i = 0; i < pdinfo->cditem; i++)
   {
      /*************************************************************/
      /* Get a pointer to the DRAGITEM                           */
      /*************************************************************/
      pditem = DrgQueryDragitemPtr (pdinfo, i);
      /*************************************************************/
      /* If we could query the source and target names, and the  */
      /* copy was successful, return success                     */
      /*************************************************************/
      if (DrgQueryStrName (pditem->hstrSourceName, sizeof (szSource),
                           szSource) &&
          DrgQueryStrName (pditem->hstrTargetName, sizeof (szTarget),
                           szTarget) &&
          !DosCopy (szSource, szTarget, 0))
      {
         flResult = DMFL_TARGETSUCCESSFUL;
      }
      /*************************************************************/
      /* Otherwise, return failure                               */
      /*************************************************************/
      else
      {
         flResult = DMFL_TARGETFAIL;
      }
      /*************************************************************/
      /* Let the source know we're done with this item           */
      /*************************************************************/
      DrgSendTransferMsg (pditem->hwndItem, DM_ENDCONVERSATION,
                          (MPARAM) pditem->ulItemID,
                          (MPARAM) flResult);
   }
   WinDestroyMsgQueue (hmq);
   WinTerminate (hab);
}

Related Functions