Page 1 of 1

Adding text with linebreaks

Posted: Wed Aug 27, 2008 11:02 am
by tuukka
Hello, it seems troublesome to find the right settings for working with string that contain linebreaks.

Basically, I have a number of strings that I want to add to RichViewEdit, for example
string1 := #13#10 + 'text begins with linebreak'
string2 := 'text with ' + #13#10 + ' linebreak in the middle'
string3 := 'text ends with linebreak ' + #13#10

Naturally, I want precisely those linebreaks and nothing else. Also, I want that there are three items and I want to obtain their texts with the linebreak included. Is this possible? They need to be separate strings since they will be in different styles and different tags.

A related question: Is there a reason that there is not a variant of function AddTextNLW that would accept a tag parameter?

Posted: Thu Aug 28, 2008 4:41 pm
by Sergey Tkachenko
Remove line break at the beginning of string1, and call:

Code: Select all

rv.AddTextNLW(string1, StyleNo1, ParaNo, ParaNo);
rv.AddTextNLW(string2, StyleNo2, -1, ParaNo);
rv.AddTextNLW(string3, StyleNo3, -1, ParaNo);
As for the tag question. It was made for consistency. All TRichView methods for adding items assign Tag parameter directly to the item's Tag. It would not be possible in tags-are-pchars mode if the method creates multiple items. It would not be good if some methods accept tag strings created by StrNew and free the memory, and other methods create copies of this string and does not free the memory.