Quote:Original post by Evil SteveQuote:Original post by TheMightyDudeTypical, that's the bit I cut out [smile]
Well it must be just me then :(
glyphMetrics.gmCellIncX = -13108 thats not right :(
Also GetGlyphOutline() is returning -1 which is GDI_ERROR isn't it?
So it's failing for some reason :(
It returns GDI_ERROR if the font isn't a truetype font. Here's the unmodified code:
*** Source Snippet Removed ***See if that's any more use...
Well i haven't tried that yet, but I know the following seems to work fine.
I wasn't too happy with the for loop but since this is only called when adding or removing text it shouldn't be too much of an issue.
I will try your code in a while.
Thanks for all your help so far :)
FLOAT CXTextBox::GetStringWidth(std::string String){ RECT String_Info; ZeroMemory(&String_Info, sizeof(RECT)); int sizeofws = 0; int found = 0; if(m_Font) { // Get the size of "." <-- closest to a whitespace :) m_Font->DrawText(NULL, ".", 1, &String_Info, DT_CALCRECT, D3DCOLOR_XRGB(0,0,0)); sizeofws = (int)String_Info.right; // Now get the size of the string. m_Font->DrawText(NULL, String.c_str(), String.length(), &String_Info, DT_CALCRECT, D3DCOLOR_XRGB(0,0,0)); // Check for any whitespaces at the end of the string. if(String[String.length()-1] == 0x20) { for(int i=String.length()-1; i>=0; i--) { if(String == 0x20) { // Found a whitespace. found++; } else { // Ok, found a non whitespace at the end just before a whitespace. // So I better break. break; } } } if (found>0) { // if found >0 calculate the extra width to add. String_Info.right += (int)(found * sizeofws); } } return (float)String_Info.right;}