在 type 區塊宣告類別與屬性後,將游標置於類別內部,按 Ctrl+Shift+C,IDE 自動生成:
F+屬性名)Get/Set+屬性名)published 區塊與屬性完整宣告implementation 區){* 1. 輸入以下類別宣告 *}
type
TMyClass = class
property S: String;
end;
{* 2. 游標放在 class...end 之間,按 Ctrl+Shift+C *}
{* 3. 自動生成完整代碼 *}
type
TMyClass = class
private
FS: String;
procedure SetS(const Value: String);
published
property S: String read FS write SetS;
end;
implementation
procedure TMyClass.SetS(const Value: String);
begin
FS := Value;
end;
| 輸入宣告 | 自動生成內容 |
|---|---|
property X: Integer read FX write SetX; | 僅生成 SetX 方法骨架 (已有 read FX) |
property Y: Boolean read GetY write SetY; | 生成 GetY、SetY 兩個方法骨架 |
procedure DoSomething; virtual; | 生成 procedure TMyClass.DoSomething; begin end; |
function Calc(A,B: Integer): Integer; | 生成函式骨架 |
constructor Create; override; | 生成建構子骨架含 inherited |
destructor Destroy; override; | 生成解構子骨架含 inherited |
class)、記錄 (record)、介面 (interface) 宣告區published 屬性、事件、方法type 區塊內的類別宣告區使用 (非 var 區)