ImageEn, unit iexRichEdit |
|
TIERichEdit.TextHeight
Declaration
function TextHeight(DestDC: HDC = 0; Width: Integer = 0): Integer;
Description
Returns the height (in pixels) of all text in the control at the specified width.
Result will be zero if there is no text.
Also see
TextSize which supports
MaxWidth.
// 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;
end;