?? unttestclass.pas
字號(hào):
unit untTestClass;
interface
uses
Classes, SysUtils, StrUtils, Dialogs, StdCtrls, Forms;
type
// Note: {$M+} 和 {$MethodInfo ON} 的順序不能寫(xiě)反
// RTTI的優(yōu)先級(jí)高于反射,因此將反射寫(xiě)在里面一層
{$M+}
{$MethodInfo ON}
TTestClass = class(TPersistent)
private
FText: string;
FX: integer;
FOnTest: TNotifyEvent;
FInnerSelf: TTestClass;
public
// 不帶參數(shù)的
procedure ShowText;
function GetText: string;
// 一個(gè)參數(shù)
procedure ShowText2(AText: string);
function Reverse(AStr: string): string;
// 二個(gè)參數(shù)
function AddInt(X,Y: Integer): Integer;
// 三個(gè)參數(shù)
function Add3(X,Y,Z: Integer): Integer;
// 對(duì)象傳入
procedure ShowCaption(AButton: TButton);
// 對(duì)象傳出
function FindButton(AForm: TForm; AName: string): TButton;
published
property Text: string read FText write FText;
property X: integer read FX write FX;
property OnTest: TNotifyEvent read FOnTest write FOnTest;
property InnerSelf: TTestClass read FInnerSelf write FInnerSelf;
end;
{$MethodInfo OFF}
{$M-}
implementation
{ TTestClass }
function TTestClass.Add3(X, Y, Z: Integer): Integer;
begin
Result := X+Y+Z;
end;
function TTestClass.AddInt(X, Y: Integer): Integer;
begin
Result := X+Y;
end;
function TTestClass.FindButton(AForm: TForm; AName: string): TButton;
begin
if AForm.FindComponent(AName) is TButton then
Result := TButton(AForm.FindComponent(AName))
else
Result := nil;
end;
function TTestClass.GetText: string;
begin
Result := FText;
end;
function TTestClass.Reverse(AStr: string): string;
begin
Result := StrUtils.ReverseString(AStr);
end;
procedure TTestClass.ShowCaption(AButton: TButton);
begin
ShowMessage(AButton.Caption);
end;
procedure TTestClass.ShowText;
begin
ShowMessage(FText);
end;
procedure TTestClass.ShowText2(AText: string);
begin
ShowMessage(AText);
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -