Put margins in a Memo  

Send By: Q3 Team
Web : www.q3.nu
Email: dlib@q3.nu
Date: 04/09/03

Tip accessed 625 times

 


It is easy sending him the EM_SETRECT message to fix the size of the canvas of the Memo.

For example:

- Create a form with a TMemo (Memo1) and a TButton (Button1)
- Put this code in the OnClick the Button1:


      procedure TForm1.Button1Click(Sender: TObject);
      var
        R : TRect;
        MargenIzquierdo:integer;  { Left Margin }
        MargenDerecho:integer;    { Right Margin }
      begin
        MargenIzquierdo:=20;
        MargenDerecho:=10;

        R := Memo1.ClientRect;
        R.Left:=R.Left + MargenIzquierdo;
        R.Top:=R.Top + 2;
        R.Bottom:=R.Bottom - 2;
        R.Right:=R.Right-MargenDerecho;
        SendMessage(Memo1.Handle, EM_SETRECT, 0, Longint(@R));
      end;



And when pressing the Button1, the Memo1 will have a left margin of 20 pixels and a right margin of 10.
If you want, you can also change the superior and the inferior.


Sent by: Nacho :

 procedure TForm1.Button1Click(Sender: TObject);
       var
         MargenIzquierdo:integer;  { Left Margin }
         MargenDerecho:integer;    { Right Margin }
       begin
         MargenIzquierdo:=20;
         MargenDerecho:=10;

         SendMessage(Memo1.Handle, EM_SETMARGINS, EC_LEFTMARGIN or
 EC_RIGHTMARGIN, MakeLong(MargenIzquierdo,MargenDerecho));
       end;




Updated at 04/09/2003 (Nacho's update)