用RichEdit显示图片,你可以自己改改这个控件,处理TRichEdit的 WM_Paint消息,画个图片。type
TMyRichEdit= class(TRichEdit)
protected
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
end;
procedure TMyRichEdit.WMPaint(var Message: TWMPaint);
var
MCanvas: TControlCanvas;
DrawBounds : TRect;
Begin
inherited;
MCanvas:=TControlCanvas.Create;
DrawBounds := ClientRect; // Work with temporary TRect record.
Try
MCanvas.Control:=Self;
With MCanvas do
Begin
Brush.Color := clBtnFace;
FrameRect( DrawBounds );
InflateRect( DrawBounds, -1, -1);
FrameRect( DrawBounds );
FillRect ( DrawBounds );
MoveTo ( 33, 0 );
Brush.Color := clWhite;
LineTo ( 33, ClientHeight );
PaintImages;//定义的画图片过程
end;
finally
MCanvas.Free;
End;
end;
TMyRichEdit= class(TRichEdit)
protected
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
end;
procedure TMyRichEdit.WMPaint(var Message: TWMPaint);
var
MCanvas: TControlCanvas;
DrawBounds : TRect;
Begin
inherited;
MCanvas:=TControlCanvas.Create;
DrawBounds := ClientRect; // Work with temporary TRect record.
Try
MCanvas.Control:=Self;
With MCanvas do
Begin
Brush.Color := clBtnFace;
FrameRect( DrawBounds );
InflateRect( DrawBounds, -1, -1);
FrameRect( DrawBounds );
FillRect ( DrawBounds );
MoveTo ( 33, 0 );
Brush.Color := clWhite;
LineTo ( 33, ClientHeight );
PaintImages;//定义的画图片过程
end;
finally
MCanvas.Free;
End;
end;
解决方案 »
- 折腾了几天了,高手帮看下-----我这个通用数据库录入&编辑基类,为什么这么不稳定?
- 怎么建立个对话框?
- 关于 注册表 清理 的原理 的问题??????????
- 在ADOQuer的AfterPost事件中出错, 如何保证数据的完整性 ?
- 谁有FASTREPORT的简单例子,有中文注释的更好!谢谢!!!
- 有关几个控件搞不懂?是什么???很急??在线???
- 你好
- 想做一个公文写作辅助软件!求教:如何在程序里精确地修改WORD文档的内容?
- 请问一个键盘的输入问题?
- 有那位想找工作的?
- 数据库中得date,integer,float类型得数据如何查询啊?急!!!
- 为什么我用指定值方式dbcombobox的值不能保存进表里?请各位帮忙
uses richedit;
{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
var
imagecanvas: TCanvas;
fmt: TFormatRange;
begin
RichEdit1.lines.LoadFromFile('C:\WINDOWS\Desktop\触摸屏程序\DOC\开发习惯.txt');
imagecanvas := image1.canvas; with fmt do begin
hdc:= imagecanvas.handle;
hdcTarget:= hdc;
// rect needs to be specified in twips (1/1440 inch) as unit
rc:= Rect(0, 0,
imagecanvas.cliprect.right * 1440 div pixelsperinch,
imagecanvas.cliprect.bottom * 1440 div pixelsperinch
);
rcPage:= rc;
chrg.cpMin := 0;
chrg.cpMax := richedit1.GetTextLen;
end; SetBkMode( imagecanvas.Handle, TRANSPARENT );
richedit1.perform( EM_FORMATRANGE, 1, integer( @fmt ));
// next call frees some cached data
richedit1.perform( EM_FORMATRANGE, 0, 0 );
image1.refresh;
// refresh is necessary since the control only refreshes automatically
// if a canvas method is used to change its content.end;end.