Board logo

Subject: To yygw:将控件和事件从published改为private的方法 [Print This Page]

Author: dark_moon    Time: 2005-1-26 13:07     Subject: To yygw:将控件和事件从published改为private的方法

代码如下:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    btn1: TButton;
  private
    procedure btn1Click(Sender : TObject);
  public
    constructor Create(AOwner : TComponent);override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.btn1Click(Sender: TObject);
begin
  //DoSomething();
end;

constructor TForm1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  btn1 := FindComponent('btn1') as TButton;
  btn1.OnClick := btn1Click;
end;

initialization
  RegisterClass(TButton);
end.




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0