CDC::GetTextExtent Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
GetTextExtentPoint32 The GetTextExtentPoint32 function computes the width and height of the specified string of text. BOOL GetTextExtentPoint32( HDC hdc, // handle to DC LPCTSTR lpString, // text string int cbString, // characters in string LPSIZE lpSize // string size );
得到size后,ExtTextOut中设置lprcExtTextOut The ExtTextOut function draws text using the currently selected font, background color, and text color. You can optionally provide dimensions to be used for clipping, opaquing, or both. BOOL ExtTextOut( HDC hdc, // handle to DC int X, // x-coordinate of reference point int Y, // y-coordinate of reference point UINT fuOptions, // text-output options CONST RECT* lprc, // optional dimensions LPCTSTR lpString, // string UINT cbCount, // number of characters in string CONST INT* lpDx // array of spacing values );
或设置DrawText参数的lpRectDrawText The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth). To specify additional formatting options, use the DrawTextEx function. int DrawText( HDC hDC, // handle to DC LPCTSTR lpString, // text to draw int nCount, // text length LPRECT lpRect, // formatting dimensions UINT uFormat // text-drawing options );
Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
The GetTextExtentPoint32 function computes the width and height of the specified string of text. BOOL GetTextExtentPoint32(
HDC hdc, // handle to DC
LPCTSTR lpString, // text string
int cbString, // characters in string
LPSIZE lpSize // string size
);
The ExtTextOut function draws text using the currently selected font, background color, and text color. You can optionally provide dimensions to be used for clipping, opaquing, or both. BOOL ExtTextOut(
HDC hdc, // handle to DC
int X, // x-coordinate of reference point
int Y, // y-coordinate of reference point
UINT fuOptions, // text-output options
CONST RECT* lprc, // optional dimensions
LPCTSTR lpString, // string
UINT cbCount, // number of characters in string
CONST INT* lpDx // array of spacing values
);
The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth). To specify additional formatting options, use the DrawTextEx function. int DrawText(
HDC hDC, // handle to DC
LPCTSTR lpString, // text to draw
int nCount, // text length
LPRECT lpRect, // formatting dimensions
UINT uFormat // text-drawing options
);