提问:如下安装后的 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 群里的问题,记录一下。

Delphi 10.4 更新如下:

unit TestGrid;

interface

uses
  System.SysUtils, System.Classes, FMX.Types, FMX.Controls,
  FMX.Controls.Model, FMX.Presentation.Factory,
  FMX.Presentation.Style, FMX.Grid.Style,
  FMX.Controls.Presentation, FMX.ScrollBox, FMX.Grid;

type
  TTestGrid = class(TStringGrid)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Test', [TTestGrid]);
end;

initialization

  RegisterFmxClasses([TTestGrid]);
  TPresentationProxyFactory.Current.Register(TTestGrid, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);

finalization

  TPresentationProxyFactory.Current.Unregister(TTestGrid, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);

end.

  [问答] Firemonkey 控件继承后无法显示(空白)

相关文章:

  • 2022-02-26
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-08-23
  • 2022-12-23
  • 2021-05-24
猜你喜欢
  • 2021-12-29
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-05-20
  • 2021-10-09
相关资源
相似解决方案