D
dyxfkj
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
Type
TcyButton = Class(TButton)
Private
Public
procedure Click(Sender: TObject);
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Panel: TPanel;
Button: TcyButton;
begin
Panel := TPanel.Create(Nil);
Panel.Parent := Form1;
with Panel do
begin
Button := TcyButton.Create(Nil);
With Button do
begin
Parent := Panel;
OnClick := Click;
end;
end;
end;
{ Button }
procedure TcyButton.Click(Sender: TObject);
begin
Showmessage('a'); //ShowMessage 是没有问题的
Close; //Close 没有办法做, cyButton不知道应该Close谁啊? ^_^ 这儿应该怎么写?
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
Type
TcyButton = Class(TButton)
Private
Public
procedure Click(Sender: TObject);
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Panel: TPanel;
Button: TcyButton;
begin
Panel := TPanel.Create(Nil);
Panel.Parent := Form1;
with Panel do
begin
Button := TcyButton.Create(Nil);
With Button do
begin
Parent := Panel;
OnClick := Click;
end;
end;
end;
{ Button }
procedure TcyButton.Click(Sender: TObject);
begin
Showmessage('a'); //ShowMessage 是没有问题的
Close; //Close 没有办法做, cyButton不知道应该Close谁啊? ^_^ 这儿应该怎么写?
end;
end.