AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

abstract error in componente

Ein Thema von EWeiss · begonnen am 19. Sep 2008 · letzter Beitrag vom 19. Sep 2008
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

abstract error in componente

  Alt 19. Sep 2008, 02:32
Habe hier jede menge abstract Fehler in einer Komponente
Das tritt auf wenn ich diese als obj einlade.

Füge ich diese direkt in das Formular ein ist es in ordnung.
Zumindest kommt keine Meldung.

Nur wenn sie als obj und in das DesignPanel von der Jedi Componente eingefügt wird.
Was kann ich da machen ?

Bild im Anhang.. und die class

Delphi-Quellcode:
unit cAVeButton;

interface

uses
  Windows,Classes, Graphics, Controls, ExtCtrls, Messages, pngimage;

type
  TcAVeButton = class(TCustomControl)
  private
    FUpPic : TPngObject;
    FDownPic : TPngObject;
    FOverPic : TPngObject;
    FBoolTruePic : TPngObject;
    FBoolFalsePic: TPngObject;
    FShowBoolPic : Boolean;
    FFixMode : Boolean;
    FTouchMode : Boolean;
    FButtonDown : Boolean;
    FBoolPicXPos : Integer;
    FBoolPicYPos : Integer;
    FLabelXPos : Integer;
    FLabelYPos : Integer;
    FAppIndex : Integer;
    FEntered : Boolean;
    FShowButton : Boolean;
    FFunktion : String;
    FAktion : String;
    FTimer: TTimer;

    procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
    procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
    procedure WMMouseEnter( var Message : TWMMouse ); message CM_MOUSEENTER;
    procedure WMMouseLeave( var Message : TWMMouse ); message CM_MOUSELEAVE;
    procedure SetDownPic(Value: TPngObject);
    procedure SetUpPic(Value: TPngObject);
    procedure SetOverPic(Value: TPngObject);
    procedure SetBoolTruePic(Value: TPngObject);
    procedure SetBoolFalsePic(Value: TPngObject);
    procedure SetText(Value: TCaption); reintroduce;
    procedure SetTouchMode(Value: Boolean);
    procedure SetFixMode(Value: Boolean);
    procedure SetShowButton(Value:Boolean);
    procedure SetShowBoolPic(Value: Boolean);
    procedure SetBoolPicXPos(Value: Integer);
    procedure SetBoolPicYPos(Value: Integer);
    procedure SetLabelXPos(Value: Integer);
    procedure SetLabelYPos(Value: Integer);
    procedure DrawParentBackground(AToDC : HDC);

  protected
    procedure Paint; override;
    procedure TimerEvent(Sender: TObject);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Funktion: String read FFunktion write FFunktion;
    property Aktion: String read FAktion write FAktion;
    property Caption write SetText;
    property UpPicture: TPngObject read FUpPic write SetUpPic;
    property DownPicture: TPngObject read FDownPic write SetDownPic;
    property OverPicture: TPngObject read FOverPic write SetOverPic;
    property BoolTruePicture: TPngObject read FBoolTruePic write SetBoolTruePic;
    property BoolFalsePicture: TPngObject read FBoolFalsePic write SetBoolFalsePic;
    property TouchMode: Boolean read FTouchMode write SetTouchMode;
    property FixMode: Boolean read FFixMode write SetFixMode;
    property ShowButton: Boolean read FShowButton write SetShowButton;
    property ShowBoolPic: Boolean read FShowBoolPic write SetShowBoolPic;
    property BoolPicXPos: Integer read FBoolPicXPos write SetBoolPicXPos;
    property BoolPicYPos: Integer read FBoolPicYPos write SetBoolPicYPos;
    property LabelXPos: Integer read FLabelXPos write SetLabelXPos;
    property LabelYPos: Integer read FLabelYPos write SetLabelYPos;
    property AppIndex: Integer read FAppIndex write FAppIndex;
    property Font;
    property OnMouseDown;
    property OnMouseUp;
    property OnClick;

  end;

procedure Register;
Delphi-Quellcode:
procedure Register;
begin
  RegisterComponents('cAVe', [TcAVeButton]);
end;
gruss Emil
Miniaturansicht angehängter Grafiken
abstract_133.jpg  
  Mit Zitat antworten Zitat
Benutzerbild von sx2008
sx2008

Registriert seit: 15. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#2

Re: abstract error in componente

  Alt 19. Sep 2008, 06:16
Dein Fehler ist schon mal, dass du eine ganz konkrete Klasse TPngObject verwendest.
Richtig wäre, die Klasse TPicture zu verwenden:
property UpPicture: TPicture read FUpPic write SetUpPic; Durch die Verwendung von TPicture kann man beliebige Bilder BMP, GIF, JPEG, PNG,... laden.
Vorraussetzung zum Laden von PNG-Bildern ist aber, dass die Unit pngimage eingebunden ist.
Diese Unit wird aber auch schon zur Entwicklungszeit benötigt!!!
Daher musst du dir ein Designtime-Package erstellen, die Unit pgnimage hinzufügen und in der IDE installieren.
Dazu muss man wissen, dass Delphi ein Plugin-System für Grafiken hat.
Nur wenn die Unit pngimage dieses Plugin-System richtig verwendet, kann die ganze Sache funktionieren.
Neue Grafiktypen müssen über TPicture.RegisterFileFormat in der VCL registriert werden.
Wenn also RegisterFileFormat im Abschnitt Initialization der Unit pngimage nicht aufgerufen wird, dann läuft etwas falsch.
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#3

Re: abstract error in componente

  Alt 19. Sep 2008, 10:33
Zitat von sx2008:
Dein Fehler ist schon mal, dass du eine ganz konkrete Klasse TPngObject verwendest.
Richtig wäre, die Klasse TPicture zu verwenden:
property UpPicture: TPicture read FUpPic write SetUpPic; Durch die Verwendung von TPicture kann man beliebige Bilder BMP, GIF, JPEG, PNG,... laden.
Vorraussetzung zum Laden von PNG-Bildern ist aber, dass die Unit pngimage eingebunden ist.
Diese Unit wird aber auch schon zur Entwicklungszeit benötigt!!!
Daher musst du dir ein Designtime-Package erstellen, die Unit pgnimage hinzufügen und in der IDE installieren.
Dazu muss man wissen, dass Delphi ein Plugin-System für Grafiken hat.
Nur wenn die Unit pngimage dieses Plugin-System richtig verwendet, kann die ganze Sache funktionieren.
Neue Grafiktypen müssen über TPicture.RegisterFileFormat in der VCL registriert werden.
Wenn also RegisterFileFormat im Abschnitt Initialization der Unit pngimage nicht aufgerufen wird, dann läuft etwas falsch.
Werde das mal testen irgend so etwas habe ich mir schon gedacht.

Delphi-Quellcode:
initialization
  {Initialize}
  ChunkClasses := nil;
  {crc table has not being computed yet}
  crc_table_computed := FALSE;
  {Register the necessary chunks for png}
  RegisterCommonChunks;
  {Registers TPNGObject to use with TPicture}
  {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
    TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics', TPNGObject);
  {$ENDIF}{$ENDIF}
finalization
  {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
    TPicture.UnregisterGraphicClass(TPNGObject);
  {$ENDIF}{$ENDIF}
  {Free chunk classes}
  FreeChunkClassList;
Wird in PngImage aufgerufen und die Componente ist im system registriert

Delphi-Quellcode:
interface

uses
  Windows,Classes, Graphics, Controls, ExtCtrls, Messages, pngimage;

type
  TcAVeButton = class(TCustomControl)
  private
    FUpPic : TPicture;
    FDownPic : TPicture;
    FOverPic : TPicture;
    FBoolTruePic : TPicture;
    FBoolFalsePic: TPicture;
    FShowBoolPic : Boolean;
    FFixMode : Boolean;
    FTouchMode : Boolean;
    FButtonDown : Boolean;
    FBoolPicXPos : Integer;
    FBoolPicYPos : Integer;
    FLabelXPos : Integer;
    FLabelYPos : Integer;
    FAppIndex : Integer;
    FEntered : Boolean;
    FShowButton : Boolean;
    FFunktion : String;
    FAktion : String;
    FTimer: TTimer;
Das ändern verursacht aber eine menge neue Fehler
[Pascal Error] cAVeButton.pas(148): E2010 Incompatible types: 'TGraphic' and 'TPicture'

usw..

Gruss Emil
  Mit Zitat antworten Zitat
Benutzerbild von littleDave
littleDave

Registriert seit: 27. Apr 2006
Ort: München
556 Beiträge
 
Delphi 7 Professional
 
#4

Re: abstract error in componente

  Alt 19. Sep 2008, 11:55
Zitat von sx2008:
Dein Fehler ist schon mal, dass du eine ganz konkrete Klasse TPngObject verwendest.
Richtig wäre, die Klasse TPicture zu verwenden:
property UpPicture: TPicture read FUpPic write SetUpPic; Durch die Verwendung von TPicture kann man beliebige Bilder BMP, GIF, JPEG, PNG,... laden.
Vorraussetzung zum Laden von PNG-Bildern ist aber, dass die Unit pngimage eingebunden ist.
Diese Unit wird aber auch schon zur Entwicklungszeit benötigt!!!
Daher musst du dir ein Designtime-Package erstellen, die Unit pgnimage hinzufügen und in der IDE installieren.
Dazu muss man wissen, dass Delphi ein Plugin-System für Grafiken hat.
Nur wenn die Unit pngimage dieses Plugin-System richtig verwendet, kann die ganze Sache funktionieren.
Neue Grafiktypen müssen über TPicture.RegisterFileFormat in der VCL registriert werden.
Wenn also RegisterFileFormat im Abschnitt Initialization der Unit pngimage nicht aufgerufen wird, dann läuft etwas falsch.
Diese Aussage stimmt zwar schon - jedoch nicht in diesem Fall: er benutzt TPngImage zur Laufzeit, somit wird kein DesignTime-Package benötigt. Ich glaube eher, dass es für den JvInspector keinen Editor für das TPngObject gibt. Somit musst du dem JvInspector erstmal einen Editor für TPngObjects bastelt. Wie genau das funktioniert, kannst du im Source vom JvInspector nachschauen - anhand der bereits eingebundenen Objekte.

So würde es jedenfalls ungefähr ausschauen:
Delphi-Quellcode:
type
  TJvInspectorPngImage = class(TJvInspectorStringItem)
  protected
    procedure Edit; override;
    function GetDisplayValue: string; override;
    procedure SetFlags(const Value: TInspectorItemFlags); override;
  end;

procedure TJvInspectorPngImage.Edit;
begin
  // Hier musst du eine Handling-Routine für ein TPngObject einbauen
end;

procedure TJvInspectorPngImage.SetFlags(const Value: TInspectorItemFlags);
var
  NewValue: TInspectorItemFlags;
begin
  // Dieser Editortyp hat einen Editor-Button (...) und der Text ist ReadOnly
  NewValue := Value + [iifEditButton, iifEditFixed];
  inherited SetFlags(NewValue);
end;

function TJvInspectorPngImage.GetDisplayValue: string;
begin
  if TPngImage(Pointer(Data.AsOrdinal)).Empty then
     result := '(leer)'
  else
     result := 'TPngImage';
end;

initialization
  TJvCustomInspectorData.ItemRegister.Add(
      TJvInspectorTypeInfoRegItem.Create(TJvInspectorPngImage, TypeInfo(TPngObject))
  );
Ich weiß jetzt nicht, ob das so alles funktioniert, ist jetzt einfach so aus dem Kopf heraus geschrieben. Ist ja nur zur verdeutlichung
Jabber: littleDave@jabber.org
in case of 1 is 0 do external raise while in public class of object array else repeat until 1 is 0
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#5

Re: abstract error in componente

  Alt 19. Sep 2008, 14:03
Danke das könnte mir helfen
Nur was ich nicht verstehe habe schon einen Typ von TPicture
über den ich PngImage einladen kann.

Delphi-Quellcode:
  TJvCustomInspectorData.ItemRegister.
  Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorPictureItem ,
                                           TypeInfo(TPicture)));
Habe es jetzt so gemacht wird aber kein bild eingeladen..


Delphi-Quellcode:
  TJvInspectorPngImage = class(TJvInspectorClassItem)
  protected
    procedure Edit; override;
    function GetDisplayValue: string; override;
  public
    constructor Create(const AParent: TJvCustomInspectorItem; const AData: TJvCustomInspectorData); override;
  end;
Delphi-Quellcode:
constructor TJvInspectorPngImage.Create(const AParent: TJvCustomInspectorItem;
  const AData: TJvCustomInspectorData);
begin
  inherited Create(AParent, AData);
  Flags := Flags + [iifEditButton, iifEditFixed];
end;


procedure TJvInspectorPngImage.Edit;
begin
  MainForm.dlgPicture.InitialDir := ExtractFilePath(Application.ExeName);
  if MainForm.dlgPicture.Execute then
  begin
    PngImageFile := MainForm.dlgPicture.Filename;
    tmpPngImage.Picture.LoadFromFile(PngImageFile);
    SkinManagerInterface.Modified := True;
  end;

  // ReInitialisiere Inspector Display Edit Button
  InitEdit;
  Inspector.Invalidate;
end;


function TJvInspectorPngImage.GetDisplayValue: string;
begin
  if TPngObject(Pointer(Data.AsOrdinal)).Empty then
    Result := 'click to edit'
  else
  begin
    Result := ExtractFileName(MainForm.dlgPicture.Filename);
    MainForm.JvDesignPanel.Invalidate;
  end;

end;
und bei 'margins' gibt es immer noch einen abstract error.
Das image 'tmpPngImage' wird erstellt in ShowSelProperties

Delphi-Quellcode:
procedure TCAVEUIObject.ShowSelProperties(Inspector: TJvInspector;
  aObj: TObject; Props: array of string; NodeText: string);
var
  i : integer;
  Category: TJvInspectorCustomCategoryItem;

begin
  Inspector.Root.Clear;

  Category := TJvInspectorCustomCategoryItem.Create(Inspector.Root, nil);
  Category.DisplayName := NodeText;
  Inspector.Root.SortKind := iskNone;

  for i:=Low(Props) to High(Props) do
    TJvInspectorPropData.New(Category, aObj, GetPropInfo(aObj, Props[i]));

  if aObj.classname = 'TImagethen
    begin
      tmpImage := TImage(aObj);
    end else
    if aObj.classname = 'TcAVeButtonthen
    begin
      tmpPngImage := TImage(aObj);
    end;


  Category.Expanded := True;
end;
Gruss Emil
  Mit Zitat antworten Zitat
Benutzerbild von littleDave
littleDave

Registriert seit: 27. Apr 2006
Ort: München
556 Beiträge
 
Delphi 7 Professional
 
#6

Re: abstract error in componente

  Alt 19. Sep 2008, 14:22
Delphi-Quellcode:
  TJvCustomInspectorData.ItemRegister.
  Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorPictureItem ,
                                           TypeInfo(TPicture)));
Du setzt hier den Editor für den Typ TPicture
Und hier verwendest du ein cast auf TPngObject:
Delphi-Quellcode:
function TJvInspectorPngImage.GetDisplayValue: string;
begin
  if TPngObject(Pointer(Data.AsOrdinal)).Empty then <--- da müsste es krachen
     { ... }
end;
Diese Zeile müsste lauten:
if TPicture(Pointer(Data.AsOrdinal)).Graphic.Empty then So, du kannst ja über den Cast schließlich auf die TPicture-Klasse zugreifen. Warum machst du das dann auch nicht hier:
Delphi-Quellcode:
procedure TJvInspectorPngImage.Edit;
begin
  { ... }
  if MainForm.dlgPicture.Execute then
  begin
    TPicture(Pointer(Data.AsOrdinal)).LoadFromFile(PngImageFile);
  end;
  { ... }
end;
Dann brauchst du auch das tmpPngImage nicht mehr.

Und mit dem abstakten Fehler: erstell mal ein Editor für die "Margins" - musst ja nichts großes machen - einfach nur mal schauen, ob sich dadurch das Problem löst
Jabber: littleDave@jabber.org
in case of 1 is 0 do external raise while in public class of object array else repeat until 1 is 0
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#7

Re: abstract error in componente

  Alt 19. Sep 2008, 14:52
Zitat:
Delphi-Quellcode:
TJvCustomInspectorData.ItemRegister.
  Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorPictureItem ,
                                           TypeInfo(TPicture)));
Du setzt hier den Editor für den Typ TPicture
Nein das ist für mein Timage object
habe nur gesagt das ich damit auch Png einladen kann und meine frage war
warum muss ich dann ein neues erstellen für PNG..

Für Png habe ich es schon richtig definiert.
Delphi-Quellcode:
  // TImage
  TJvCustomInspectorData.ItemRegister.
  Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorPictureItem ,
                                           TypeInfo(TPicture)));
  // Png
  TJvCustomInspectorData.ItemRegister.
  Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorPngImage,
                                         TypeInfo(TPngObject)));
so geht es nun .. Danke für die Tips

Delphi-Quellcode:
procedure TJvInspectorPngImage.Edit;
begin
  MainForm.dlgPicture.InitialDir := ExtractFilePath(Application.ExeName);
  if MainForm.dlgPicture.Execute then
  begin
    PngImageFile := MainForm.dlgPicture.Filename;
    TPngObject(Pointer(Data.AsOrdinal)).LoadFromFile(PngImageFile);
    SkinManagerInterface.Modified := True;
  end;

  // ReInitialisiere Inspector Display Edit Button
  InitEdit;
  Inspector.Invalidate;
end;
  Mit Zitat antworten Zitat
Benutzerbild von littleDave
littleDave

Registriert seit: 27. Apr 2006
Ort: München
556 Beiträge
 
Delphi 7 Professional
 
#8

Re: abstract error in componente

  Alt 19. Sep 2008, 14:56
Da bin ich wohl etwas durcheinander gekommen aber jetzt gehts ja
Jabber: littleDave@jabber.org
in case of 1 is 0 do external raise while in public class of object array else repeat until 1 is 0
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:34 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