delphi 关闭窗体
来源:百度知道 编辑:UC知道 时间:2024/06/13 23:59:18
不要在一个个控件的单击事件里写CLOSE;
有没有更加方便的方法??
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,TypInfo;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure oncloseclick(sender:TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
vMethod: TMethod;
vEvent: TNotifyEvent;
i:integer;
begin
vEvent := oncloseclick;
vMethod.Code := @vEvent; //************ Code 1
vMethod.Data := Self;
for i:=0 to ControlCount-1 do
begin
if IsPublishedProp(Controls[i], 'onclick') then