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


    提问:如下安装后的 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.

      

  • 相关阅读:
    ●BZOJ 3926 [Zjoi2015]诸神眷顾的幻想乡
    ●BZOJ 1396 识别子串
    ●UVA 1608 Non-boring sequences
    ●SPOJ 8222 NSUBSTR–Substrings
    ●SPOJ 7258 Lexicographical Substring Search
    ●CodeForces 429D Trick_Function
    ●BZOJ 2555 SubString
    ●洛谷P2664 树上游戏
    ●洛谷P3168 [CQOI2015]任务查询系统
    【UVA1057】Routing
  • 原文地址:https://www.cnblogs.com/onechen/p/6219144.html
Copyright © 2020-2023  润新知