简体   繁体   中英

How to decrease line space of tRichEdit

I use tRichEdit to set line colors. I want to decrease line space like tMemo.

When I input an alphabet manually the line space decreases automatically but when I use tRichEdit.lines.add nothing happens.

If it's not possible are there any substitutes?

在此处输入图片说明

You can adjust line spacing by sending the EM_SETPARAFORMAT via SendMessage , setting PFM_LINESPACING in the dwMask and providing values for the dyLineSpacing value (and setting the bLineSpacingRule value so that the RichEdit knows how to interpret the former). The code below sets a very tight linespacing in the TRichEdit (the lines actually slightly overlap each other):

procedure TForm1.FormCreate(Sender: TObject);
var
  Para: TParaFormat2;
begin
  Para.cbSize := SizeOf(Para);
  Para.dwMask := PFM_LINESPACING;
  Para.bLineSpacingRule := 4;  // Use exact twips specified
  Para.dyLineSpacing := 120;   // Ridiculously small value
  SendMessage(RichEdit1.Handle, EM_SETPARAFORMAT, 0, LPARAM(@Para));
end;

For more information, see the MSDN documentation for EM_SETPARAFORMAT

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