简体   繁体   中英

TRichEdit - How to add an empty line with size change?

I have array of strings and i want to add an empty line of lesser size between some of them. So i have a code:

  const _n=#13#10;
  //...
  r1.Lines.Clear;
  r1.SelAttributes.Size:=18;
  r1.SelText:='TEST';
  r1.SelAttributes.Size:=6;
  r1.SelText:=_n+'............';
  r1.SelAttributes.Size:=18;
  r1.SelText:=_n+'test1';
  r1.SelAttributes.Size:=6;
  r1.SelText:=_n+' ';
  r1.SelAttributes.Size:=18;
  r1.SelText:=_n+'test2';

and size change works for first line (with dots), but line between test1 and test2 has same size as they (18) somehow =\\

Any suggestions?

I found some workaround: it's possible to use tab-symbol in place of space.

So the following code works fine:

  r1.SelAttributes.Size:=18;
  r1.SelText:=_n+'test1';
  r1.SelAttributes.Size:=6;
  r1.SelText:=_n+#9; // <- tab here
  r1.SelAttributes.Size:=18;
  r1.SelText:=_n+'test2';

Instead of inserting empty lines you could change the line spacing of individual lines by sending EM_SETPARAFORMAT messages to the Richedit. See this question

How to decrease line space of tRichEdit

for an example. To increase the line spacing change the value of "Para.dyLineSpacing". Use "500" to get an idea of the effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM