TPanel的父亲(TCustomPanel)的父亲(TCustomControl)有Canvas属性,
不过TPanel没有将它public出来。你可以这样用:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TMyPanel = class(TPanel)
end;
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
//这样就可以用他的Canvas属性了
//TMyPanel(Panel1).Canvas
end;
end.