I have a text control with RICH_TEXT2 style enabled. In this control I want to write a sentence and within a loop highlight one word at a time...so for instance, write the sentence "One day at a time." to the text control, then on the first iteration of the loop highlight the word "One", then on the next iteration highlight "day", etc. The code works except for the first iteration, and the first word in the text control does not get highlighted. The code snippet that actually manipulates the text control is as follows:
Code: Select all
SentenceTC -> Clear();
SentenceTC -> AppendText(currentSentence -> sentence.GetData());
startingPosition = currentSentence -> sentence.Find(currWord -> word.GetData());
wordLength = currWord -> word.Length();
endingPosition = startingPosition + wordLength;
SentenceTC -> SetStyle(startingPosition, endingPosition, wordStyle);
I also tried to update the control (SentenceTC -> Update()), but that has no effect. I also tried setting RICH_TEXT style which didn't have any effect either.
I am running this under Windows XP.
Any ideas why this doesn't work for the first word or what I could do to make it work?
Thanks in advance for any advice.