Jump to content

GpiQueryCharBox

From EDM2
Revision as of 21:24, 6 April 2025 by Iturbide (talk | contribs) (Created page with "This function returns the current value of the character box attribute, as set by the GpiSetCharBox function. ==Syntax== GpiQueryCharBox(hps, psizfxSize) ==Parameters== ; hps (HPS) - input : Presentation-space handle. ; psizfxSize (PSIZEF) - output : Character-box size. : If the character box is currently set to the default, the default size is returned. This is the size returned by DevQueryCaps (CAPS_GRAPHICS_CHAR_WIDTH and CAPS_GRAPHICS_CHAR_HEIGHT), co...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function returns the current value of the character box attribute, as set by the GpiSetCharBox function.

Syntax

GpiQueryCharBox(hps, psizfxSize)

Parameters

hps (HPS) - input
Presentation-space handle.
psizfxSize (PSIZEF) - output
Character-box size.
If the character box is currently set to the default, the default size is returned. This is the size returned by DevQueryCaps (CAPS_GRAPHICS_CHAR_WIDTH and CAPS_GRAPHICS_CHAR_HEIGHT), converted to presentation page space.

Return Value

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

Remarks

In general this function does not return the same box as GpiQueryTextBox for an average-sized character. For outline fonts the character-box attribute is mapped to a particular font dimension related to the point size, for raster fonts it does not correspond to any font metric. (See GpiSetCharMode). This function is invalid when the drawing mode (see GpiSetDrawingMode) is set to retain.

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_IN_RETAIN_MODE (0x208C)
An attempt was made to issue a function (for example, query) that is invalid when the actual drawing mode is not draw or draw-and-retain.
PMERR_INV_DC_TYPE (0x2060)
An invalid type parameter was specified with DevOpenDC, or a function was issued that is invalid for a OD_METAFILE_NOQUERY device context.

Example Code

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

HPS     hps;        /* Presentation-space handle. */
PSIZEF  psizfxSize; /* Character-box size. */
BOOL    rc;         /* Success indicator. */

rc = GpiQueryCharBox(hps, psizfxSize);

This example uses GpiQueryCharBox to return the current value of the character box attribute, as set by the GpiSetCharBox call; if successful, places the box width in a variable.

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

BOOL fSuccess; /* success indicator */
HPS hps; /* Presentation-space handle */
SIZEF psizfxSize; /* Character-box size */
FIXED lWidth; /* character box width */

fSuccess = GpiQueryCharBox(hps, &psizfxSize);
if (fSuccess == TRUE)
  lWidth = psizfxSize.cx;

Related Functions