Jump to content

DrgAddStrHandle

From EDM2
Revision as of 16:38, 7 November 2023 by Ak120 (talk | contribs)

This function creates a handle to a string.

Syntax

DrgAddStrHandle(pString)

Parameters

pString (PSZ) - input
String for which a handle is to be created.

Returns

hstr (HSTR) - returns
String handle.
NULLHANDLE - Error occurred.
Other - String handle created.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_PARAMETERS (0x1208)
An application parameter value is invalid for its converted PM type. For example: a 4-byte value outside the range -32 768 to +32 767 cannot be converted to a SHORT, and a negative number cannot be converted to a ULONG or USHORT.
PMERR_RESOURCE_DEPLETION (0x20F9)
An internal resource depletion error has occurred.

Remarks

The handle can be used by any application to reference the input string.

This function must be called by the source of a drag whenever a string is to be passed in a DRAGINFO structure.

Example Code

This example calls the DrgAddStrHandle function to create handles for strings that are used in a DRAGITEM structure.

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

USHORT   ID_ITEM = 1;   /* Drag item identifier                  */
HWND     hwnd;          /* Window handle                         */
DRAGITEM ditem;         /* DRAGITEM structure                    */

                        /* Initialize the DRAGITEM structure     */
ditem.hwndItem = hwnd;          /* Conversation partner          */
ditem.ulItemID = ID_ITEM;       /* Identifies item being dragged */
ditem.hstrType = DrgAddStrHandle(DRT_TEXT);     /*  Item is text */
ditem.hstrRMF = DrgAddStrHandle("<DRM_OS2FILE,DRF_TEXT>");
ditem.hstrContainerName = DrgAddStrHandle("C:\\");
ditem.hstrSourceName = DrgAddStrHandle("C:\\CONFIG.SYS");
ditem.hstrTargetName = DrgAddStrHandle("C:\\OS2\\CONFIG.SYS");
ditem.cxOffset = 0;             /* X-offset of the origin of the */
                                /* image from the pointer hotspot*/
ditem.cyOffset = 0;             /* Y-offset of the origin of the */
                                /* image from the pointer hotspot*/
ditem.fsControl = 0;            /* Source item control flags     */
                                /* object is open                */
ditem.fsSupportedOps = 0;

Related Functions

  • DrgDeleteStrHandle
  • DrgQueryStrName