Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Delphi 10.1 Berlin Komponente ableiten (https://www.delphipraxis.net/190465-delphi-10-1-berlin-komponente-ableiten.html)

KWin 6. Okt 2016 15:16

Delphi 10.1 Berlin Komponente ableiten
 
Hallo,

ich bin vor kurzem auf Delphi 10.1 Berlin umgestiegen.
Seit dem habe ich ein Problem mit einer von TStringGrid abgeleitetet Komponente.
Die Installation in einem Packages verläuft erfolgreich.
Nach dem Hereinziehen der Komponte steht:

------
Für die Klasse MwStringGrid wurde kein TStyledPresentationProxi- Nachkomme registriert.
Eventuell muss das FMX.Grid.Style Modul in den uses.ABschnitt eingefügt werden.
------

Weiß jemand, was da noch zu machen ist?


Hier der extrem komplizierte Code der Komponente:

unit FMX.MwStringGrid;

Delphi-Quellcode:
{$I ToolStep7.inc}

interface

uses
  System.SysUtils, System.Classes,
  FMX.Grid.Style,
  FMX.Types, FMX.Controls, FMX.Grid;

type
  TMwStringGrid = class(TStringGrid)
  private
  protected
  public
  published
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MaxWell', [TMwStringGrid]);
end;


end.

himitsu 6. Okt 2016 16:29

AW: Delphi 10.1 Berlin Komponente ableiten
 
Du mußt in deinem Grid scheinbar nur noch die Methode DefinePresentationName überschreiben

http://stackoverflow.com/questions/3...ered-for-class
Delphi-Quellcode:
function TfmGrid.DefinePresentationName: string;
begin
  Result := 'Grid-' + GetPresentationSuffix;
end;

KWin 6. Okt 2016 21:30

AW: Delphi 10.1 Berlin Komponente ableiten
 
Danke, für die Antwort.

Bei einmaliger Ableitung funktionierts.

Delphi-Quellcode:
//-----------------------------------------------------------------------------
function TMwStringGrid.DefinePresentationName: string;
begin
  inherited;
  Result := 'Grid-' + GetPresentationSuffix;
end;

bei der zweiten Ableitung steht mann wieder vor dem gleichen Problem.

Lösung: Entscheidender Hinweis stand im Link zu Stackoverflow.

(Auskommenntierter Teil funktioniert bei der 2. Ableitung nicht.)

Delphi-Quellcode:
unit FMX.MwStringGrid;

{$I ToolStep7.inc}

interface

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

type
  TMwStringGrid = class(TStringGrid)
  private
  protected
//    function DefinePresentationName: string; override;
  public
  published
  end;

type
  TMwStringGrid01 = class(TMwStringGrid)
  private
  protected
//   function DefinePresentationName: string; override;
  public
  published
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MaxWell', [TMwStringGrid]);
  RegisterComponents('MaxWell', [TMwStringGrid01]);
end;

(*
//-----------------------------------------------------------------------------
function TMwStringGrid.DefinePresentationName: string;
begin
  inherited;
  Result := 'Grid-' + GetPresentationSuffix;
end;

//-----------------------------------------------------------------------------
function TMwStringGrid01.DefinePresentationName: string;
begin
  inherited;
  Result := 'Grid01-' + GetPresentationSuffix;
end;
*)

initialization
  TPresentationProxyFactory.Current.Register(TMwStringGrid, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);
  TPresentationProxyFactory.Current.Register(TMwStringGrid01, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);
finalization
  TPresentationProxyFactory.Current.Unregister(TMwStringGrid, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);
  TPresentationProxyFactory.Current.Unregister(TMwStringGrid01, TControlType.Styled, TStyledPresentationProxy<TStyledGrid>);
end.


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz