Jump to content

GpiCharStringAt: Difference between revisions

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


==Parameters==
==Parameters==
; ''hps'' ([[HPS]]) - input
; ''hps'' ([[HPS]]) - input: Presentation-space handle.
: Presentation-space handle.
; ''pptlPoint'' ([[PPOINTL]]) - input: Starting position.
 
; ''pptlPoint'' ([[PPOINTL]]) - input
: Starting position.
: Defines, in world coordinates, the position at which the first character in the string is to be placed.
: Defines, in world coordinates, the position at which the first character in the string is to be placed.
 
; ''lCount'' ([[LONG]]) - input: Number of bytes in the string.
; ''lCount'' ([[LONG]]) - input
: Number of bytes in the string.
: Must be greater than 0 and less or equal to 512.
: Must be greater than 0 and less or equal to 512.
 
; ''pchString'' ([[PCH]]) - input: Characters to be drawn.
; ''pchString'' ([[PCH]]) - input
: Characters to be drawn.
: This parameter does not need to be null terminated.
: This parameter does not need to be null terminated.


==Return Value==
==Return Value==
; ''lHits'' ([[LONG]]) - returns
; ''lHits'' ([[LONG]]) - returns: Correlation and error indicators.
: Correlation and error indicators.
::GPI_OK: Successful
:; GPI_OK
::GPI_HITS: Correlate hits
:: Successful
::GPI_ERROR: Error.
:; GPI_HITS
:: Correlate hits
:; GPI_ERROR
:: Error.


==Remarks==
==Remarks==
Line 44: Line 33:
==Errors==
==Errors==
Possible returns from WinGetLastError:
Possible returns from WinGetLastError:
; PMERR_INV_HPS (0x207F)
; PMERR_INV_HPS (0x207F): An invalid presentation-space handle was specified.
: 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_PS_BUSY (0x20F4)
; PMERR_INV_COORDINATE (0x205B): An invalid coordinate value was specified.
: An attempt was made to access the presentation space from more than one thread simultaneously.
; PMERR_INV_LENGTH_OR_COUNT (0x2092): An invalid length or count parameter was specified.
; PMERR_INV_COORDINATE (0x205B)
; PMERR_FONT_AND_MODE_MISMATCH (0x202D): An attempt was made to draw characters with a character mode and character set that are incompatible. For example, the character specifies an image/raster font when the mode calls for a vector/outline font.
: An invalid coordinate value was specified.
; PMERR_INV_LENGTH_OR_COUNT (0x2092)
: An invalid length or count parameter was specified.
; PMERR_FONT_AND_MODE_MISMATCH (0x202D)
: An attempt was made to draw characters with a character mode and character set that are incompatible. For example, the character specifies an image/raster font when the mode calls for a vector/outline font.


==Graphic Elements and Orders==
==Graphic Elements and Orders==
Line 60: Line 44:


==Example Code==
==Example Code==
<PRE>
#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */
#include &lt;os2.h&gt;
HPS    hps;        /* Presentation-space handle. */
PPOINTL pptlPoint;  /* Starting position. */
LONG    lCount;      /* Number of bytes in the string. */
PCH    pchString;  /* Characters to be drawn. */
LONG    lHits;      /* Correlation and error indicators. */
lHits = GpiCharStringAt(hps, pptlPoint, lCount, pchString);
</PRE>
This example uses the GpiCharStringAt function to draw the string "Hello" starting at the position (100,100). It then uses the GpiMove and GpiCharString functions to draw the same string at exactly the same position.
This example uses the GpiCharStringAt function to draw the string "Hello" starting at the position (100,100). It then uses the GpiMove and GpiCharString functions to draw the same string at exactly the same position.
<pre>
<pre>
#define INCL_GPIPRIMITIVES /* GPI primitive functions */
#define INCL_GPIPRIMITIVES /* GPI primitive functions */
#include &lt;os2.h&gt;
#include <os2.h>


HPS hps; /* presentation space handle */
HPS hps; /* presentation space handle */

Latest revision as of 01:44, 24 November 2025

This function draws a character string starting at a specified position.

Syntax

GpiCharStringAt(hps, pptlPoint, lCount, pchString)

Parameters

hps (HPS) - input
Presentation-space handle.
pptlPoint (PPOINTL) - input
Starting position.
Defines, in world coordinates, the position at which the first character in the string is to be placed.
lCount (LONG) - input
Number of bytes in the string.
Must be greater than 0 and less or equal to 512.
pchString (PCH) - input
Characters to be drawn.
This parameter does not need to be null terminated.

Return Value

lHits (LONG) - returns
Correlation and error indicators.
GPI_OK: Successful
GPI_HITS: Correlate hits
GPI_ERROR: Error.

Remarks

The function GpiCharStringAt (hps, point, count, string) is equivalent to:

Each character in the string is positioned so that its character reference point is at the current position. The current position is advanced after each character is drawn to give the position for the next character.

The font from which the characters in the character string are selected depends on the current character mode. For a description of which fonts are used for each of the possible modes, see GpiSetCharMode.

The degree to which approximation of the position and size is allowed, and also the area used during correlation of the character string, is controlled by the character-mode attribute.

After the string has been drawn, the current position is set to the end of the character string. This is the point at which the next character would have been drawn, had it existed.

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_COORDINATE (0x205B)
An invalid coordinate value was specified.
PMERR_INV_LENGTH_OR_COUNT (0x2092)
An invalid length or count parameter was specified.
PMERR_FONT_AND_MODE_MISMATCH (0x202D)
An attempt was made to draw characters with a character mode and character set that are incompatible. For example, the character specifies an image/raster font when the mode calls for a vector/outline font.

Graphic Elements and Orders

Element Type: OCODE_GCHSTM Order: Character String Move at Given Position

Example Code

This example uses the GpiCharStringAt function to draw the string "Hello" starting at the position (100,100). It then uses the GpiMove and GpiCharString functions to draw the same string at exactly the same position.

#define INCL_GPIPRIMITIVES /* GPI primitive functions */
#include <os2.h>

HPS hps; /* presentation space handle */
POINTL ptlStart;

ptlStart.x = 100L;
ptlStart.y = 100L;

/* Draw the string "Hello" at (100, 100). */
GpiCharStringAt(hps, &ptlStart, 5, "Hello");

/* These two calls are identical to the one above. */
GpiMove(hps, &ptlStart);
GpiCharString(hps, 5L, "Hello");

Related Functions