Search code examples
delphizoomingrichedit

Delphi - RichEdit Zoom with code


If you load some text in the richedit and click left mouse button + move the mouse wheel, the text will zoom in or out, without loosing the text size formatting.

Is there an easy way to implement this functionality (zoom in/out) with some lines of code?

Thank you

ray


Solution

  • You can send EM_SETZOOM to the rich edit control to sets the zoom ratio

    procedure SetZoom(const RichEdit: TCustomRichEdit; const Value: Integer);
    const
      EM_SETZOOM = (WM_USER + 225);
    begin
      SendMessage(RichEdit.Handle, EM_SETZOOM, Value, 100);
    end;
    
    procedure TForm26.btn1Click(Sender: TObject);
    begin
      SetZoom(RichEdit1, 200);
    end;