DrgSetDragImage: Difference between revisions
Appearance
Created page with "This function sets the image that is being dragged. ==Syntax== DrgSetDragImage(pdinfo, pdimg, cdimg, pRsvd) ==Parameters== ;pdinfo (PDRAGINFO) - input: Pointer to the DRAGINFO structure representing the drag operation for which the pointer is to be set. ;pdimg (PDRAGIMAGE) - input: Pointer to an array of DRAGIMAGE structures. :: These structures describe the images to be drawn under the pointer during the drag. ;cdimg (ULONG) - input: Number of DRAGIMAGE structure..." |
No edit summary |
||
Line 25: | Line 25: | ||
;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_INSUFFICIENT_MEMORY (0x203E): The operation terminated through insufficient memory. | ;PMERR_INSUFFICIENT_MEMORY (0x203E): The operation terminated through insufficient memory. | ||
==Example Code== | |||
This example sets the icon image that is displayed during a direct manipulation operation. | |||
<pre> | |||
#define INCL_GPIBITMAPS /* GPI Bit Map Functions */ | |||
#define INCL_WINSTDDRAG /* Direct Manipulation (Drag) Functions */ | |||
#include <os2.h> | |||
#define ID_BITMAP 257 /* .rc file: "bitmap 257 drgimage.bmp" */ | |||
HPS hps; /* Presentation space handle */ | |||
BOOL flResult; | |||
HAB hab; | |||
PDRAGINFO pdinfo; | |||
DRAGIMAGE dimg; | |||
HBITMAP hbm; /* Bit-map handle */ | |||
HWND hwnd; | |||
/*****************************************************************/ | |||
/* Load a bit map for use as a drag image */ | |||
/*****************************************************************/ | |||
case WM_CREATE: | |||
hps = WinGetPS(hwnd); | |||
hbm = GpiLoadBitmap(hps,0L,ID_BITMAP,20L,20L); | |||
WinReleasePS(hps); | |||
break; | |||
case DM_DRAGOVER: | |||
/*****************************************************************/ | |||
/* Initialize the DRAGIMAGE structure */ | |||
/*****************************************************************/ | |||
dimg.cb = sizeof(DRAGIMAGE); /* Size control block */ | |||
dimg.cptl = 0; | |||
dimg.hImage = hbm; /* Image handle passed to */ | |||
/* DrgDrag */ | |||
dimg.sizlStretch.cx = 20L; /* Size to stretch ico or */ | |||
dimg.sizlStretch.cy = 20L; /* bmp to */ | |||
dimg.fl = DRG_BITMAP | | |||
DRG_STRETCH; /* Stretch to size specified */ | |||
dimg.cxOffset = 0; /* Offset of the origin of */ | |||
dimg.cyOffset = 0; /* the image from the pointer */ | |||
/* hotspot */ | |||
/*****************************************************************/ | |||
/* Set the drag image */ | |||
/*****************************************************************/ | |||
flResult= DrgSetDragImage(pdinfo,&dimg,(ULONG)sizeof(dimg), NULL); | |||
</pre> | |||
==Related Functions== | |||
* [[DrgSetDragPointer]] | |||
[[Category:Drg]] | [[Category:Drg]] |
Latest revision as of 05:10, 8 April 2025
This function sets the image that is being dragged.
Syntax
DrgSetDragImage(pdinfo, pdimg, cdimg, pRsvd)
Parameters
- pdinfo (PDRAGINFO) - input
- Pointer to the DRAGINFO structure representing the drag operation for which the pointer is to be set.
- pdimg (PDRAGIMAGE) - input
- Pointer to an array of DRAGIMAGE structures.
- These structures describe the images to be drawn under the pointer during the drag.
- cdimg (ULONG) - input
- Number of DRAGIMAGE structures in the pdimg array.
- pRsvd (PVOID) - input
- Reserved value, must be NULL.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE - Successful completion.
- FALSE - Error occurred.
Remarks
The image that is set with DrgSetDragImage is used only while the pointer is over the target that made the call. If the pointer leaves the original target, the new target can specify an image by calling DrgSetDragImage. If the new target does not call DrgSetDragImage, the original image that was supplied on the call to DrgDrag is used.
Errors
Possible returns from WinGetLastError:
- PMERR_ACCESS_DENIED (0x150D)
- The memory block was not allocated properly.
- 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_INSUFFICIENT_MEMORY (0x203E)
- The operation terminated through insufficient memory.
Example Code
This example sets the icon image that is displayed during a direct manipulation operation.
#define INCL_GPIBITMAPS /* GPI Bit Map Functions */ #define INCL_WINSTDDRAG /* Direct Manipulation (Drag) Functions */ #include <os2.h> #define ID_BITMAP 257 /* .rc file: "bitmap 257 drgimage.bmp" */ HPS hps; /* Presentation space handle */ BOOL flResult; HAB hab; PDRAGINFO pdinfo; DRAGIMAGE dimg; HBITMAP hbm; /* Bit-map handle */ HWND hwnd; /*****************************************************************/ /* Load a bit map for use as a drag image */ /*****************************************************************/ case WM_CREATE: hps = WinGetPS(hwnd); hbm = GpiLoadBitmap(hps,0L,ID_BITMAP,20L,20L); WinReleasePS(hps); break; case DM_DRAGOVER: /*****************************************************************/ /* Initialize the DRAGIMAGE structure */ /*****************************************************************/ dimg.cb = sizeof(DRAGIMAGE); /* Size control block */ dimg.cptl = 0; dimg.hImage = hbm; /* Image handle passed to */ /* DrgDrag */ dimg.sizlStretch.cx = 20L; /* Size to stretch ico or */ dimg.sizlStretch.cy = 20L; /* bmp to */ dimg.fl = DRG_BITMAP | DRG_STRETCH; /* Stretch to size specified */ dimg.cxOffset = 0; /* Offset of the origin of */ dimg.cyOffset = 0; /* the image from the pointer */ /* hotspot */ /*****************************************************************/ /* Set the drag image */ /*****************************************************************/ flResult= DrgSetDragImage(pdinfo,&dimg,(ULONG)sizeof(dimg), NULL);