MIAMEX 148: Calculate String Length or Height

xcall MIAMEX, MX_GDICALC, opcode, handle, status {,params}

(Windows/ATE) MX_GDICALC performs various calculations on the length and/or height of a string as it will appear when printed. In the case of a rectangle, it will also break the string into two parts, the first of which will fit within the rectangle, the remainder of which will be printed in another space or on the next page.

Parameters

opcode  (Num)  [in]

Symbol

Value

Description

MXGDI_OPENPTR

1

Open a printer device context

MXGDI_SETFONT

2

Choose font

MXGDI_CALCRECT

3

Calculate rectangular text metrics

MXGDI_CALCLEN

4

Calculate string length

MXGDI_CLOSEPTR

5

Close printer context. This must be done BEFORE printing to it. Syntax: xcall MIAMEX, MX_GDICALC, MXGDI_CLOSEPTR, handle, status

MXGDI_CALCRECTX

6

Calculate rectangular XTEXT metrics

Definition file: ashell.def

 

handle  (B,4)  [in/out]

The handle variable is returned by the open operation (opcode 1) and must be specified to all the others.

status  (F,6)  [out]

This will be returned from each operation, with 0=success. All others are errors, with the most typical being MX_GDICALC Status Codes.

See the sample program MMOGDI.BP in EXLIB:[908,37] and the sample text file TSTGDI.TXT in EXLIB:[908,37] for examples of using MX_GDICALC and /TEXTRECTANGLE.