2.2.6.8.5 DeviceContext::GetTextExtent

Description

Computes the width and height of a line of text on the attribute device context using the current font to determine the dimensions.

Syntax

SIZE GetTextExtent( const string & str )

Parameters

str
[input] A string object.

Return

The dimensions of the string (in logical units) in a SIZE structure.

Examples

EX1

void DeviceContext_GetTextExtent_ex2()
{
    WorksheetPage testWks = Project.WorksheetPages(0);
    Window wnd = testWks.GetWindow();
    DeviceContext dc = wnd.GetDC();
    SIZE sz[10];
    string strCheck = "ABC";
    sz[2] = dc.GetTextExtent(strCheck);
    out_int("x_width = ", sz[2].cx);
    out_int("y_width = ", sz[2].cy);
}

Remark

See Also

Header to Include

origin.h