Board index » delphi » Need left margin in Rich Edit control!

Need left margin in Rich Edit control!

I'm having difficulty setting an on-screen left margin of 5-10 pixels in
the rich edit control.  In other words, I'd like to shift the text in
the rich edit box to the right by 5-10 pixels to create a small left
margin. Using the TMemo control, I was able to achieve this result with
the perform method, resetting the memo's rectangle with code like this
(the idea coming from this great forum, I might add!):

var
  theRect: TRect;

begin
  {Update rectangle for MainMemo to maintain left margin}
theRect := Rect(10, 0, MainMemo.Width, MainMemo.Height);
MainMemo.Perform(EM_SETRECTNP,0,longint(@theRect));
end;

But this code does not appear to work with the rich edit control.  Any
ideas, PLEASE?
--
Roger C. Spaeder [spae...@ix.netcom.com] {*word*269}ia

 

Re:Need left margin in Rich Edit control!


I'm having difficulty setting an on-screen left margin of 5-10 pixels in
the rich edit control.  In other words, I'd like to shift the text in
the rich edit box to the right by 5-10 pixels to create a small left
margin. Using the TMemo control, I was able to achieve this result with
the perform method, resetting the memo's rectangle with code like this
(the idea coming from this great forum, I might add!):

var
  theRect: TRect;

begin
  {Update rectangle for MainMemo to maintain left margin}
theRect := Rect(10, 0, MainMemo.Width, MainMemo.Height);
MainMemo.Perform(EM_SETRECTNP,0,longint(@theRect));
end;

But this code does not appear to work with the rich edit control.  Any
ideas, PLEASE?

--
Roger C. Spaeder [spae...@ix.netcom.com] {*word*269}ia

Re:Need left margin in Rich Edit control!


The following will work for you.

Procedure SetLeftMargin;
  var
    Indent: Integer;
  begin
    Indent := Round(-1 * (Form1.Memo1.Font.Height) * 72 /
(Form1.Memo1.Font.PixelsPerInch));
    Form1.Memo1.Hide;
    Form1.Memo1.SelectAll;
    Form1.Memo1.Paragraph.FirstIndent := Indent;
    Form1.Memo1.Paragraph.LeftIndent :=  Indent;
    If WinNT3X then
      Form1.Memo1.Paragraph.RightIndent := Indent + 10
    else If Win954X then
       Form1.Memo1.Paragraph.RightIndent := Indent + 1;
    Form1.Memo1.SelStart :=0;
    Form1.Memo1.SelLength := 0;
    Form1.Memo1.Show;
  end;
----------------------------------------------------------------------
Subject: Need left margin in Rich Edit control!
From: "Roger C. Spaeder" <spae...@ix.netcom.com>
Date: Sun, 30 Jun 1996 20:35:42 -0400
Message-ID: <31D71D5E.29@ix.netcom.com>

I'm having difficulty setting an on-screen left margin of 5-10 pixels in
the rich edit control.  In other words, I'd like to shift the text in
the rich edit box to the right by 5-10 pixels to create a small left
margin. Using the TMemo control, I was able to achieve this result with
the perform method, resetting the memo's rectangle with code like this
(the idea coming from this great forum, I might add!):

var
  theRect: TRect;

begin
  {Update rectangle for MainMemo to maintain left margin}
theRect := Rect(10, 0, MainMemo.Width, MainMemo.Height);
MainMemo.Perform(EM_SETRECTNP,0,longint(@theRect));
end;

But this code does not appear to work with the rich edit control.  Any
ideas, PLEASE?
--
Roger C. Spaeder [spae...@ix.netcom.com] {*word*269}ia

Other Threads