虽然用普通的方法RichEdit是不能显示图片的,但你可以用Canvas来画上去!如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, jpeg, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure RichEdit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
MyCanvas: TControlCanvas;
Begin
MyCanvas:=TControlCanvas.Create;
Mycanvas.control:=RichEdit1;//想在RichEdit1上作画
With Mycanvas do
Begin
//这里可以更改为你的作图程序
Draw(0,0,image1.Picture.Graphic);
Font.Color := clRed;
Brush.Style := bsClear;
TextOut(10,10,'在RichEdit中显示图片');
end;
End;
procedure TForm1.RichEdit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
RichEdit1.Brush.Style := bsClear;
end;
end.