加入声音如上,实际严格来说不是加到Memo中的。。。。。
如果要 贴图 需要 定义一个 Memo子类,处理memo的 WM_Paint消息,画个图片。
type
TMyMemo = class(TMemo)
protected
procedure WMPaint(var Message: TWMPaint);
message WM_PAINT;//消息处理句柄
end;
procedure TMyMemo.WMPaint(var Message: TWMPaint);
var
MCanvas: TControlCanvas;
DrawBounds : TRect;
begin
inherited;
//调用上层消息处理过程
MCanvas:=TControlCanvas.Create;
//建立一个画板
DrawBounds := ClientRect;
Try
MCanvas.Control:=Self;
With MCanvasdo
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;
procedure TMyMemo.PaintImages;//画图方法
var
MCanvas: TControlCanvas;
DrawBounds : TRect;
i, j : Integer;
OriginalRegion : HRGN;
ControlDC : HDC;
begin
MCanvas:=TControlCanvas.Create;
DrawBounds := ClientRect;
// Work with temporary TRect record.
try
MCanvas.Control:=Self;
ControlDC := GetDC ( Handle );
MCanvas.Draw(0, 1, Application.Icon);
finally
MCanvas.Free;
end;
代码摘自《超级猛料》