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 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
AddFormattedText
Keyboard 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\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
| Cut |
| Copy |
| Paste |
| Delete |
| SelectAll |
| Print |
Table Methods
OLE Objects