|
-
Sep 7th, 2001, 06:37 AM
#1
Width of text...
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
-
Sep 9th, 2001, 06:59 AM
#2
Code:
GetExtentPoint32(HDC, LPCTSTR, UINT, PSIZE)
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.).
In MFC it is called GetTextExtent
Code:
CSize CDC::GetTextExtent(LPTSTR, UINT);
CSize CDC::GetTextExtent(CString&);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 9th, 2001, 09:10 AM
#3
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....
-
Sep 9th, 2001, 09:31 AM
#4
Yes, I misspelled it. Of course it's GetTextExtentPoint32 (like GetTextExtent in MFC)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|