How can I find the width of a string...
So if i had.
"This is the text that would be in a text box."
How can I create a RECT that would have the width and height of this string.
Thanx
Printable View
How can I find the width of a string...
So if i had.
"This is the text that would be in a text box."
How can I create a RECT that would have the width and height of this string.
Thanx
You supply the device context, the string, it's length and a SIZE variable that is filled with the size of the string with the current settings (font, font size etc.).Code:GetExtentPoint32(HDC, LPCTSTR, UINT, PSIZE)
In MFC it is called GetTextExtent
Code:CSize CDC::GetTextExtent(LPTSTR, UINT);
CSize CDC::GetTextExtent(CString&);
The MFC CDC:: method I knew about. But I like the idea of GetExtentPoint32 better - with ONE big problem.
I can't find it at MSDN, or in my version of api toolshed. Did you misspell the api by some chance? Or maybe I can't type....
Yes, I misspelled it. Of course it's GetTextExtentPoint32 (like GetTextExtent in MFC)