What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?
Generally it is a hard challenge to implement mechanism of dividing text into lines which then fit into the editBox width and then justify the text and then to be able to scroll down/up the text, making selection, putting with the aid of mause the caret which suit perfect. And it is hard for me to believe that there aren't any simple functions. At least in DirectX utility You have CDXUTEditBox which is only one-line. There isn't multiline editbox. That is why I am implementing multiline editBox based on CDXUTEditBox. I know that there is some built-in in WINAPI editBox but I want to have my own class like CDXUTControls (because in this way I can modify background, transparency etc.etc.) As far as my function is concerned this is its the last form:
void Buffer::transformText(i32 width)
if(analyse() != OK)
const SCRIPT_LOGATTR* pLogAttr = ScriptString_pLogAttr(mAnalysis);
i32 limit = *ScriptString_pcOutChars(mAnalysis);
//calculate number of words
u32 numWords = 1;
for(i32 i=0; i<limit - 1; ++i) //without '\0'
if(pLogAttr[i].fWordStop && mBuffer[i] != '\n') //'\n' is also softBreak, charStop and wordStop
i32 fromBegX = 0;
i32 charNr = 0;
for(i32 i=0; i<limit - 1; ++i)
if((pLogAttr[i].fWhiteSpace && !pLogAttr[i+1].fWhiteSpace) || mBuffer[i] == '\n')
CPtoX(i, FALSE, &X);
if(width >= X-fromBegX)
charNr = i; //remember the last succeed char number
fromBegX += width;
znaczniki.push_back(charNr); //charNr will be replaced with '\n'
i32 size = static_cast<i32>(znaczniki.size());
for(i32 i = 0; i<size; ++i)
mBuffer[znaczniki[i]] = '\n';
It divide the text very well into editBoxWidth, but the implementation isn't good because when I change the first ' ' into '\n' then all my calculations char positions into X coordinate aren't true. And I have to change the implementation again and again, it is easy for me but it is time consuming (I am implementing all the day the mechanism. But generally the question is HOW IN THE MOST EASIEST WAY divide text into lines which suit to editBox width and then justify text. What is more we use only ID3DXFont::DrawTextW, ScriptStringAnalyse and similar Script functions. We assume that we don't use any SetTextAlign (because we cannot mess both setTextAlign and DrawTextW). Is any simple way or my approach isn't a waste of time because the reality is that there aren't any easy built-in functions to do this?