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 and the updated sample text file TSTGDI.TXT in the EXLIB for examples of using MX_GDICALC and /TEXTRECTANGLE.

History

2011 August, A-Shell 5.1.1229:  Several bug fixes and documentation revisions.

2008 August, A-Shell 5.1.1121:  Support added for the font width parameter.

2005 May, A-Shell 4.9.932:  Routine added to A-Shell.