1. Home
  2. Computing & Technology
  3. Delphi Programming

How to set margins in a TMemo Delphi Control

By , About.com Guide

To set margins in a memo control, EM_SETRECT message is sent to Memo to fix the size of the canvas of the component.

//set margins for Memo1
var
  R : TRect;
  LeftMargin:integer;
  RightMargin:integer;
begin
  LeftMargin:=20;
  RightMargin:=10;

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


Ever needed to set some additional properties to the standard Memo component? By default you use the Tmemo when you need a standard Windows multiline edit control on a form. Here are some nifty TMemo related tips and tricks

Delphi tips navigator:
» Get Windows Temp directory
« TImage.Bitmap fade out

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TImage
  6. How to set margins in a TMemo Delphi Control

©2009 About.com, a part of The New York Times Company.

All rights reserved.