请问大家:
1、richedit的行间距能不能调整?我找了一下好像不能,有没有三方控件可以实现,要求d7和d2010均可以使用的控件。
2、向richedit写入数据时,垂直滚动条有时在最顶端,有时在最下端,好像不是固定的,有随机的可能?需要专门设置?
3、谢谢大家!

解决方案 »

  1.   

    网上的代码,不太行
    uses
      RichEdit;
    {$R *.dfm}procedure RE_SetLineSpacing(ARichEdit: TRichEdit; lineSpacing: Byte);
    var
      pf2: ParaFormat2;
    begin
      FillChar(pf2, SizeOf(pf2), 0);
      pf2.cbSize := SizeOf(ParaFormat2);
      pf2.dwMask := PFM_LINESPACING;
      pf2.bLineSpacingRule := lineSpacing;
      SendMessage(ARichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@pf2));
    end;// Example:   Setlinespacing   to   1:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      RichEdit1.SelectAll;
      RE_SetLineSpacing(RichEdit1, strtoint(edit1.Text));
    end;
      

  2.   

    edit1.Text:=1、2、3、4等会出现问题
      

  3.   

    {
     0 Single spacing. The dyLineSpacing member is ignored. 
    1 One and a half spacing. The dyLineSpacing member is ignored. 
    2 Double spacing. The dyLineSpacing member is ignored. 
    3 The dyLineSpacing member specifies the spacing, in twips, from one line to the next.
            However, if dyLineSpacing specifies a value that is less than single spacing,
            the control displays single-spaced text.
    4 The dyLineSpacing member specifies the spacing, in twips, from one line to the next.
          The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is
           less than single spacing.
    5 The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next.
          Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double-spaced,
          60 is triple-spaced, and so on.
    }
    //bLineSpacingRule为3,4,5时,dyLineSpacing值才有效
    procedure TMyMemo.SetLineSpacing(LineSpacingRule:Byte;lineSpacing:Byte);
    var
      pf2:ParaFormat2;
    begin
       try
          FillChar(pf2,SizeOf(pf2),0);
          pf2.cbSize:=SizeOf(PARAFORMAT2);
          pf2.dwMask:=PFM_LINESPACING;
          pf2.bLineSpacingRule:=LineSpacingRule;
          pf2.dyLineSpacing:=lineSpacing;
          if self.SelLength = 0 then
          begin
             self.SelectAll;
             SendMessage(self.Handle,EM_SETPARAFORMAT,0,LParam(@pf2));
             self.SelLength := 0;
          end
          else
          begin
             SendMessage(self.Handle,EM_SETPARAFORMAT,0,LParam(@pf2));
          end;
       except on E:Exception do
          begin
             WriteLog('MyMemo.SetLineSpacing Error:' + E.Message);
          end;
       end;
    end;