Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BouncePup

strange error...

This topic is 5930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m using the following code to insert & format text into a Subclassed richedit ctrl.. ********** int iTotalLen = GetWindowTextLength(); SetSel(iTotalLen, iTotalLen); ReplaceSel(szData); int iStartPos = iTotalLen; CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD; cf.dwEffects = (unsigned long) ~( CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD); cf.crTextColor = crColor; int iEndPos = GetWindowTextLength(); SetSel(iStartPos, iEndPos); SetSelectionCharFormat(cf); HideSelection(TRUE, FALSE); LineScroll(1); ********** Yet this seems to happen when I insert data into the control using the above code: -=IMG=- www.dyaus.com/weird1.jpg Any ideas on either how to fix it or how to do it properly? Regards, Nate Strandberg

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I am assuming that your crColor is red. If that is the case then the problem seems to me to be that you are adding the text, but the SetSel calls are not selecting the just written text properly and you end up only coloring a portion of each string. I don''t really know why the start and end positions wouldn''t be correct, but maybe GetWindowTextLength is not correctly counting the carriage return/line feed pairs at the end of each string. Just a guess.

Share this post


Link to post
Share on other sites
Yeah.. If I take out the new line ("\n") it colorizes it fine..

Any idea how to properly count everything?

-Nate

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can tell how many carrage return/line feed pairs you have by taking the line count (GetLineCount()) and either adding or subtracting that from the GetWindowTextLength() depending on whether or not it is counting them or not. My guess is that GetWindowTextLength() is counting CR/LF pairs, but SetSel is not. Maybe it is the other way around. Anyway, counting the lines may help.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!