提問:如下安裝後的 TMyPanel 能在設計期時正常顯示,但 TMyPanel2 在設計期時是白板,不能正常看到,為什麼?
TMyPanel = class(TPanel)
end;
TMyCustomPanel = class(TPanel)
TMyPanel2 = class(TMyCustomPanel)
end;
RegisterComponent('Test', [TMyPanel, TMyPanel2]);
可能:是隔代無法繼承 Style 造成的,改成如下就可以了:
TMyPanel = class(TPanel)
end;
TMyCustomPanel = class(TPanel)
end;
TMyPanel2 = class(TMyCustomPanel)
protected
function GetDefaultStyleLookupName: string; override;
end;
function TMyPanel2.GetDefaultStyleLookupName: string;
begin
Result := 'panelstyle';
end;
ps. 這裡 QQ 群裡的問題,記錄一下。