ImageEn, unit iexRichEdit |
|
TIERichEdit
Declaration
TIERichEdit = class(TCustomRichEdit);
Description
TIERichEdit is a descendent of TRichEdit with support for RichEdit 8.0 functionality, including:
- Enhanced text and paragraph formatting
- Get and set rich text by property (
RTFText property)
- Automatic hover toolbar when editing text (
AutoToolbar property)
- Automatic
customizable popup menu (if you do not assign your own)
- Keyboard shortcuts built-in
- Import and export to PDF and Microsoft Word, if available (
ImportFromWord/
ExportToWord methods)
- Support for embedded images and objects
-
Insertion and
editing of tables
- Paint formatted text to a TBitmap or TIEBitmap (
PaintTo method)
- Enhanced Find and Replace
- Multi-level undo
-
Spell checking- Automatic URL detection (
AutoURLDetect property)
- Bidirectional support

Note: Do not use IERichEdit1.Lines.Add(...); use
AddLine or
AddFormattedTextKeyboard Shortcuts
The default
keyboard shortcuts are as follows:
Description | Type | Shortcut |
Cut to Clipboard | iesCut | Ctrl+X |
Copy to Clipboard | iesCopy | Ctrl+C |
Paste from Clipboard | iesPaste | Ctrl+V |
Align text left | iesLeftAlign | Ctrl+L |
Center text | iesCenterAlign | Ctrl+E |
Align text right | iesRightAlign | Ctrl+R |
Justify text | iesJustified | Ctrl+J |
Apply bold formatting | iesBold | Ctrl+B |
Apply italic formatting | iesItalic | Ctrl+I |
Apply underline formatting | iesUnderline | Ctrl+U |
Open the Font dialog box | iesFontSelect | Ctrl+D |
Removes all formatting from selection | iesClearFormatting | Ctrl+Space |
Decrease the size of the font | iesDecreaseFontSize | Ctrl+Comma |
Increase the size of the font | iesIncreaseFontSize | Ctrl+Period |
Show Find dialog | iesFind | Ctrl+F |
Find Next | iesFindNext | Shift+F4 |
Show Replace dialog | iesReplace | Ctrl+H |
Select all text | iesSelectAll | Ctrl+A |
Single line spacing | - | Ctrl+1 |
Double line spacing | - | Ctrl+2 |
1.5 line spacing | - | Ctrl+5 |
Demos
| Demos\Other\RichEdit\RichEdit.dpr |
| Demos\Actions\Actions_IERichEdit\RichEditActions.dpr |
Examples
// Set plain text in Editor
Editor.Text := 'Some Text';
// Set rich text in Editor
Editor.RTFText := #123'\rtf1\ansi\ansicpg1252\deff0'#123'\fonttbl'#123'\f0\fnil\fcharset0 Tahoma;'#125#125'\viewkind4\uc1\pard\lang1033\b\f0\fs24 ImageEn!\b0\par'#125;
// Show a hover toolbar when editing text
IEGlobalSettings().RichEditorToolbar.Position := iepAbove;
Editor.AutoToolbar := True;

// Hide buttons for Bullets and Numbering
IEGlobalSettings().RichEditorToolbar.Buttons := IEGlobalSettings().RichEditorToolbar.Buttons - [irbRichEditBullets];
// Import a Word document
Editor.ImportFromWord( 'D:\MyDoc.docx' );
// Export to PDF
Editor.ExportToWord( 'D:\MyDoc.pdf' );
// Paint rich editor content to TImageEnView
const
Text_Margin = 30;
var
bmp : TIEBitmap;
imgW, imgH, textW, textH: Integer;
textRect: TRect;
begin
imgW := ImageEnView1.Width;
imgH := ImageEnView1.Height;
textW := imgW - 2 * Text_Margin;
// Calc height of text at this width
textH := Editor.MeasureText( 0, textW ).Y;
textRect := Rect( Text_Margin,
Text_Margin,
Text_Margin + textW,
Text_Margin + textH );
bmp := TIEBitmap.Create;
try
bmp.width := imgW;
bmp.height := imgH;
// Load an image to use as background?
if not ( chkUseEditorBackground.checked or chkEnableAlpha.checked ) then
bmp.Read('D:\TextBackground.jpg');
Editor.PaintTo( bmp, textRect, iehLeft, ievTop, chkUseEditorBackground.checked, chkEnableAlpha.checked );
ImageEnView1.Assign(bmp);
finally
bmp.Free;
end;
// Paint rich editor content to TImage
const
Text_Margin = 30;
var
bmp: TBitmap;
imgW, imgH, textW, textH: Integer;
textRect: TRect;
begin
imgW := Image1.Width;
imgH := Image1.Height;
textW := imgW - 2 * Text_Margin;
// Calc height of text at this width
textH := Editor.MeasureText( 0, textW ).Y;
textRect := Rect( Text_Margin,
Text_Margin,
Text_Margin + textW,
Text_Margin + textH );
bmp := TBitmap.Create;
try
bmp.width := imgW;
bmp.height := imgH;
// Load an image to use as background?
if not chkUseEditorBackground.checked then
bmp.LoadFromFile('D:\TextBackground.bmp');
Editor.PaintTo( bmp, textRect, iehLeft, ievTop, chkUseEditorBackground.checked );
Image1.Picture.Assign(bmp);
finally
bmp.Free;
end;
end;
// Output an RTF file as an image
const
Out_Width = 500;
Out_Height = 800;
Text_Margin = 20;
var
re : TIERichEdit;
bmp: TIEBitmap;
textRect: TRect;
begin
bmp := TIEBitmap.Create;
re := TIERichEdit.CreateParented(HWND(HWND_MESSAGE));
try
re.Visible := False;
re.WordWrap := False;
re.OpenFromFile( 'D:\RTF Document.rtf' );
bmp.width := Out_Width;
bmp.height := Out_Height;
textRect := Rect( Text_Margin,
Text_Margin,
Out_Width - Text_Margin,
Out_Height - Text_Margin );
re.PaintTo( bmp, textRect, iehCenter, ievCenter, True );
bmp.Write('D:\RtfImage.jpeg' );
finally
bmp.Free;
re.Free;
end;
end;
Methods and Properties
General
Input/Output
Formatting
Find and Replace
Undo/Redo
| Cut |
| Copy |
| Paste |
| Delete |
| SelectAll |
| Print |
Table Methods
OLE Objects
Events