回 帖 发 新 帖 刷新版面

主题:Memo的背景修改

memo的背景只能进行色彩变化,太单调,我想用图片代替,不知怎样能实现?请帮忙!

回复列表 (共1个回复)

沙发

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Image1: TImage; //建立一个Image控件,并加入一幅图片;
    Button1: TButton;
    procedure WinControlDrawImage(WinControl: TWinControl; Graphic: TGraphic);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WinControlDrawImage(WinControl: TWinControl; Graphic: TGraphic);
var // 最少的代码绘画TWinControl组件的图形
MCanvas: TControlCanvas;
begin
MCanvas := TControlCanvas.Create;
try
MCanvas.Control := WinControl;
MCanvas.StretchDraw(MCanvas.ClipRect, Graphic);
finally
MCanvas.Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
WinControlDrawImage(Memo1, Image1.Picture.Graphic);
end;

end.

我来回复

您尚未登录,请登录后再回复。点此登录或注册