Jump to content

DrgAddStrHandle: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
No edit summary
 
Line 5: Line 5:


==Parameters==  
==Parameters==  
; pString (PSZ) - input: String for which a handle is to be created.
; pString ([[PSZ]]) - input: String for which a handle is to be created.


==Returns==
==Returns==
; hstr (HSTR) - returns: String handle.
; hstr ([[HSTR]]) - returns: String handle.
::NULLHANDLE - Error occurred.
::NULLHANDLE - Error occurred.
::Other - String handle created.
::Other - String handle created.


==Errors==
==Errors==
Possible returns from WinGetLastError
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_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.
;PMERR_RESOURCE_DEPLETION (0x20F9):An internal resource depletion error has occurred.


Line 23: Line 23:


==Example Code==
==Example Code==
This example calls the DrgAddStrHandle function to create handles for strings that are used in a DRAGITEM structure.
This example calls the DrgAddStrHandle function to create handles for strings that are used in a [[DRAGITEM]] structure.
<pre>
<pre>
#define INCL_WINSTDDRAG /* Direct Manipulation (Drag) Functions  */
#define INCL_WINSTDDRAG /* Direct Manipulation (Drag) Functions  */
Line 50: Line 50:


==Related Functions==
==Related Functions==
* DrgDeleteStrHandle
* [[DrgDeleteStrHandle]]
* DrgQueryStrName
* [[DrgQueryStrName]]
   
   
[[Category:Drg]]
[[Category:Drg]]

Latest revision as of 03:31, 25 April 2025

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