📄 initunit.pas
字号:
unit InitUnit;
interface
uses Classes;
function Mz_InitInheritedComponent(Instance: TComponent; RootAncestor: TClass; const DfmData: string): Boolean;
implementation
function Mz_InternalReadComponentData(var Instance: TComponent; const DfmData: string): Boolean;
var
StrStream: TStringStream;
begin
StrStream := nil;
try
StrStream := TStringStream.Create(DfmData);
Instance := StrStream.ReadComponent(Instance);
finally
StrStream.Free;
end;
Result := True;
end;
function Mz_InitInheritedComponent(Instance: TComponent; RootAncestor: TClass; const DfmData: string): Boolean;
function Mz_InitComponent(ClassType: TClass; const DfmData: string): Boolean;
begin
Result := False;
if (ClassType = TComponent) or (ClassType = RootAncestor) then Exit;
Result := Mz_InitComponent(ClassType.ClassParent, DfmData);
Result := Mz_InternalReadComponentData(Instance, DfmData) or Result; // **
end;
var
LocalizeLoading: Boolean;
begin
GlobalNameSpace.BeginWrite; // hold lock across all ancestor loads (performance)
try
LocalizeLoading := (Instance.ComponentState * [csInline, csLoading]) = [];
if LocalizeLoading then BeginGlobalLoading; // push new loadlist onto stack
try
Result := Mz_InitComponent(Instance.ClassType, DfmData); // **
if LocalizeLoading then NotifyGlobalLoading; // call Loaded
finally
if LocalizeLoading then EndGlobalLoading; // pop loadlist off stack
end;
finally
GlobalNameSpace.EndWrite;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -