Subroutines > Detailed Descriptions > MIAMEX

MIAMEX 148: Calculate String Length or Height

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

(Windows/ATE) This function (148 or 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

 

handle  (B4)  [in/out]

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

status  (F6)  [out]

This will be returned from each operation, with 0=success; all others are errors, with the most typical being:

Status

Description

-1

Unable to open printer context (bad printer name or failure to first open printer)

-2

Bad map mode

-3

Error setting font

-4

Insufficient number of parameters passed

-5

Illegal opcode

-6

File transfer error (server was unable to transfer file to the ATE client for MXGDI_CALCRECTX processing)

-7

File spec error - invalid or not present (MXGDI_CALCRECTX)

-8

This error means that you have specified a rectangle that has zero or negative space. (This error previously displayed a cryptic "Printing Area Too Small" message.)

-15

ATE failure to respond

others

Negative of the system error number

 

See the sample program MMOGDI.BP and the updated sample text file TSTGDI.TXT in the SOSLIB for examples of using XCALL MIAMEX,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.