这两个事件都是一样的结果,就很疑惑他们到底有什么区别,请求给解释下,感谢了.
procedure TForm1.Button1Click(Sender: TObject);
var
S1: String;
begin
SetLength (S1, 100);
GetWindowText (Handle, PChar (S1), Length (S1));
Button1.Caption := S1;
end;
////////////////////////////////////////////////////////////
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Caption := Form1.Caption;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S1: String;
begin
SetLength (S1, 100);
GetWindowText (Handle, PChar (S1), Length (S1));
Button1.Caption := S1;
end;
////////////////////////////////////////////////////////////
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Caption := Form1.Caption;
end;
var
S1: String;
begin
SetLength (S1, 100);
GetWindowText (Handle, PChar (S1), Length (S1));// 通过WinAPI函数,获取指定窗口的标题
Button1.Caption := S1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button2.Caption := Form1.Caption;//直接用delphi属性赋值语句实现;
end;
第二种是通过窗体对象获取属性,简洁,常用