Функция API GetTextExtentPoint32() The GetTextExtentPoint32 function computes the width and height of the specified string of text.
BOOL GetTextExtentPoint32(
HDC hdc, // handle of device context
LPCTSTR lpString, // address of text string
int cbString, // number of characters in string
LPSIZE lpSize // address of structure for string size
);