如何减少tRichEdit的行距 [英] How to decrease line space of tRichEdit

查看:87
本文介绍了如何减少tRichEdit的行距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用tRichEdit设置线条颜色.我想减少行距,例如tMemo.

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

当我手动输入字母时,行距会自动减小,但是当我使用tRichEdit.lines.add时,什么也不会发生.

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?

推荐答案

您可以通过以下方式调整行距:通过 SendMessage 发送 EM_SETPARAFORMAT ,设置 PFM_LINESPACING dwMask 中的code>并为 dyLineSpacing 值提供值(并设置 bLineSpacingRule 值,以便RichEdit知道如何解释前者).下面的代码在 TRichEdit 中设置了非常紧密的换行符(行实际上彼此稍微重叠了):

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;

有关更多信息,请参见 EM_SETPARAFORMAT

For more information, see the MSDN documentation for EM_SETPARAFORMAT

这篇关于如何减少tRichEdit的行距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆