Visible屬性在設計時被忽略。所有關於可見性的信息只存儲在幀的dfm中。 使用框架將窗體中可見的實例設置爲true將不會存儲在窗體的dfm中。手動添加它不會有幫助,它會在下次保存時被忽略並刪除。
澄清之後,可以用例如屬性顏色。 在設計時創建一個框架顏色clBlack,在Form中使用了2個框架,顏色設置爲clRed和clBlue。
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TCallOnCreate=Procedure(Sender:TObject) of object;
TFrame7 = class(TFrame)
Button1: TButton;
Procedure Loaded;override;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
Public Constructor Create(AOwner:TComponent);Override;
end;
implementation
uses RTTI;
{$R *.dfm}
{ TFrame7 }
constructor TFrame7.Create(AOwner: TComponent);
var
ToCall : TCallOnCreate;
Routine : TMethod;
begin
inherited;
Showmessage('Created ' + IntToStr(Color));
Routine.Data := Pointer(AOwner);
Routine.Code := AOwner.MethodAddress('InfoOnFrameCreate');
if Assigned(Routine.Code) then
begin
ToCall:= TCallOnCreate(Routine);
ToCall(Self);
end;
end;
procedure TFrame7.Loaded;
begin
inherited;
Showmessage('Loaded ' + IntToStr(Color));
end;
end.
通過以下示例,如何在將要使用Frame的Form中實現代碼。
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit7;
type
TForm6 = class(TForm)
Frame71: TFrame7;
Procedure InfoOnFrameCreate(Sender:TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
{ TForm6 }
procedure TForm6.InfoOnFrameCreate(Sender: TObject);
begin
Showmessage('Frame Created');
end;
end.
已經想通了,但謝謝你的明確答案。 – gamliela