| ImageEn, unit iexRichEdit |
|
TIERichEdit
Properties · Methods · Events · Demos · Examples
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
◼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
AddFormattedText
The default
keyboard shortcuts are as follows:
| Description | Type | Shortcut |
| Cut to Clipboard | ieksCut | Ctrl+X |
| Copy to Clipboard | ieksCopy | Ctrl+C |
| Paste from Clipboard | ieksPaste | Ctrl+V |
| Align text left | ieksLeftAlign | Ctrl+L |
| Center text | ieksCenterAlign | Ctrl+E |
| Align text right | ieksRightAlign | Ctrl+R |
| Justify text | ieksJustified | Ctrl+J |
| Apply bold formatting | ieksBold | Ctrl+B |
| Apply italic formatting | ieksItalic | Ctrl+I |
| Apply underline formatting | ieksUnderline | Ctrl+U |
| Open the Font dialog box | ieksFontSelect | Ctrl+D |
| Removes all formatting from selection | ieksClearFormatting | Ctrl+Space |
| Decrease the size of the font | ieksDecreaseFontSize | Ctrl+Comma |
| Increase the size of the font | ieksIncreaseFontSize | Ctrl+Period |
| Show Find dialog | ieksFind | Ctrl+F |
| Find Next | ieksFindNext | Shift+F4 |
| Show Replace dialog | ieksReplace | Ctrl+H |
| Select all text | ieksSelectAll | Ctrl+A |
| Single line spacing | - | Ctrl+1 |
| Double line spacing | - | Ctrl+2 |
| 1.5 line spacing | - | Ctrl+5 |
| Undo the last action | ieksUndo | Ctrl+Z |
| Redo the last action | ieksRedo | Ctrl+Y |
| Zoom into the image | ieksZoomIn | Ctrl+Plus |
| Zoom out of the image | ieksZoomOut | Ctrl+Minus |
| Reset the Zoom to 100% | ieksResetZoom | Ctrl+0 |
| Demos\Other\RichEdit\RichEdit.dpr |
| Demos\Actions\Actions_IERichEdit\RichEditActions.dpr |
// Set plain text in Editor
IERichEdit1.Text := 'Some Text';
// Set rich text in Editor
IERichEdit1.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;
IERichEdit1.AutoToolbar := True;

// Hide buttons for Bullets and Numbering
IEGlobalSettings().RichEditorToolbar.Buttons := IEGlobalSettings().RichEditorToolbar.Buttons - [irbRichEditBullets];
// Center the current paragraph
IERichEdit1.Paragraph.Alignment := paCenter;
// Bold the selected text
IERichEdit1.SelAttributes.Bold := True;
// Import a Word document
IERichEdit1.ImportFromWord( 'D:\MyDoc.docx' );
// Export to PDF
IERichEdit1.ExportToWord( 'D:\MyDoc.pdf' );
// Insert a web link
IERichEdit1.InsertLink( 'http://www.ImageEn.com', 'ImageEn Web Site' );
// 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 := IERichEdit1.TextHeight( 0, textW );
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.LoadFromFile('D:\TextBackground.jpg');
IERichEdit1.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 := IERichEdit1.TextHeight( 0, textW );
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');
IERichEdit1.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.SaveToFile('D:\RtfImage.jpeg' );
finally
bmp.Free;
re.Free;
end;
end;
General
Input/Output
Formatting
Find and Replace
Undo/Redo
Text Methods
Table Methods
OLE Objects