I used the following code to add margins to RichEdit. How can I change their background color?
procedure TForm1.Button1Click(Sender: TObject);
var
   LRect: TRect;
begin
   LRect := RichEdit1.ClientRect;
   InflateRect(LRect, -25, -25); 
   RichEdit1.Perform(EM_SETRECT, 0, Integer(@LRect));
end;
				
                        
EM_SETRECTmerely tells the RichEdit the rectangle where it is allowed to render its text. To change the background color of the margin you are reserving space for, you will have to subclass the RichEdit to handleWM_PAINTmessages directly, then you can draw whatever you want in that space.