CDC::DrawText
The syntax
int DrawText( const CString& str, LPRECT lpRect, UINT nFormat );
We dont know the width and height of the rectangle where the text to display, so that the lpRect is empty
Then how calculate the text area ?
It is simple,
Eg:
CRect rcText( 0, 0, 0 ,0 );
dc.DrawText( csText, &rcText, DT_CALCRECT );
dc.DrawText( csText, &rcText, DT_CENTER );
The first DrawText fills rcText with required value, ie the hight of the text, width of the text.
Call next DrawText, then the text will display.
The return of the DrawText is the height of the text. But we also have to calculate the width of the text. So the above method is easy to use.
No comments yet.
Leave a comment
-
Archives
- September 2008 (1)
- August 2008 (4)
- July 2008 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS