2014-02-18 31 views
0

我在窗體上點擊按鈕時,表單標題會變成按鈕。下面是我的工作結束代碼。嘗試指派功能時發生不兼容錯誤點擊事件

type 
    TForm1 = class(TForm) 
    Button1: TButton; 

    procedure FormShow(Sender: TObject); 
    procedure setcaption(Sender: TObject); 
    private 
     { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    Form1: TForm1; 

implementation 

{$R *.dfm} 
{ TForm1 } 

procedure TForm1.setcaption (Sender: TObject); 
begin 
    ((sender as tbutton).Parent as tform).Caption := 'Success...'; 
end; 


procedure TForm1.FormShow(Sender: TObject); 
begin 
    Button1.OnClick := setcaption(sender); 
end; 

得到錯誤

[Error] Unit1.pas(38): Incompatible types: 'TNotifyEvent' and 'procedure, untyped pointer or untyped parameter' 

請糾正我的錯誤,我是新來這個概念......

+0

IDE更容易在.dfm文件中設置它。同樣替換'((sender as tbutton).Parent as tform).Caption:='Success ...';'帶'Caption:='成功...';' –

回答

相關問題