Jump to content

GpiOffsetElementPointer

From EDM2
Revision as of 22:39, 6 April 2025 by Iturbide (talk | contribs) (Created page with "This function sets the element pointer, within the current segment, to the current value plus the specified offset. ==Syntax== GpiOffsetElementPointer(hps, loffset) ==Parameters== ; hps (HPS) - input : Presentation-space handle. ; loffset (LONG) - input : Offset to be added to the element pointer. ==Return Value== ; rc (BOOL) - returns : Success indicator. :; TRUE :: Successful completion :; FALSE :: Error occurred. ==Remarks== If the resulting value is...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function sets the element pointer, within the current segment, to the current value plus the specified offset.

Syntax

GpiOffsetElementPointer(hps, loffset)

Parameters

hps (HPS) - input
Presentation-space handle.
loffset (LONG) - input
Offset to be added to the element pointer.

Return Value

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Remarks

If the resulting value is negative, the element pointer is set to 0. If the resulting value is greater than the number of elements in the segment, it is set to the last element. This function is only valid when the drawing mode (see GpiSetDrawingMode) is set to retain (not draw-and-retain), and a segment bracket is currently in progress. This function is invalid within an element bracket.

Errors

Possible returns from WinGetLastError

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_INV_MICROPS_FUNCTION (0x20A1)
An attempt was made to issue a function that is invalid in a micro presentation space.
PMERR_NOT_IN_RETAIN_MODE (0x20E2)
An attempt was made to issue a segment editing element function that is invalid when the actual drawing mode is not set to retain.
PMERR_NO_CURRENT_SEG (0x20E6)
An attempt has been made to issue GpiQueryElementType or GpiQueryElement while there is no currently open segment.
PMERR_INV_IN_ELEMENT (0x2089)
An attempt was made to issue a function invalid inside an element bracket.

Example Code

#define INCL_GPISEGEDITING /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HPS  hps;     /* Presentation-space handle. */
LONG loffset; /* Offset to be added to the element pointer. */
BOOL rc;      /* Success indicator. */

rc = GpiOffsetElementPointer(hps, loffset);

This example uses the GpiOffsetElementPointer function to move to the element associated with a label element. Combining the GpiSetElementPointerAtLabel and GpiOffsetElementPointer functions is a convenient way to locate elements in segments that have been edited.

#define INCL_GPISEGEDITING /* GPI Segment Edit functions */
#define INCL_GPISEGMENTS /* Segment functions */
#include <os2.h>

HPS hps; /* presentation space handle */
POINTL ptlStart = { 0, 0 }; /* first vertex */
POINTL ptlTriangle[] = { 100, 100, 200, 0, 0, 0 }; /* vertices */

GpiOpenSegment(hps, 4L); /* creates a segment with labels */
GpiLabel(hps, 5L); GpiMove(hps, &ptlStart);
GpiLabel(hps, 10L); GpiPolyLine(hps, 3L, ptlTriangle);
GpiCloseSegment(hps);

.
.
.

GpiOpenSegment(hps, 4L);
GpiSetElementPointerAtLabel(hps, 10L);/* move to label 10 */
GpiOffsetElementPointer(hps, 1L); /* move to polyline element */

Related Functions