Autor Beitrag
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 10.08.06 10:54 
Hallo

ich habe folgenden Code in einer Komponente:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
type  
  TAxis = class(TObject)
  private
    FRect : TRect;
    FCaption : String;
    FFont : TFont;
    FMax : Double;
    FMin : Double;
    FMaxList : array[0..9] of Double;
    FMinList : array[0..9] of Double;
    FS : Double;
    FSteps : Integer;
    FTicks : Integer;
    FUnit : String;
    FVisible : Boolean;
    FSmallTicks : Integer;
    FAxisOrientation : TAxisOrientation;

    procedure SetMax(Value : Double);
    procedure SetMin(Value : Double);

    function GetMaxFromList : Double;
    function GetMinFromList : Double;
  protected
    procedure Normalize(var nMin : Double; var nMax : Double; var Pot : Integer);
    function CalcTickDistance(Min, Max : Double; Ticks : Integer) : Double;
    function GetTicks(Min, Max : Double; S : Double) : Integer;
    procedure Paint(Canvas : TCanvas; ARect : TRect);
  public
    constructor Create;
    destructor Destroy; override;

    property Steps : Integer read FSteps;

    procedure ScaleMinMax(MinVal, MaxVal : Double);
  published
    property Caption : String read FCaption write FCaption;
    property Font : TFont read FFont write FFont;
    property Maximum : Double read FMax write SetMax;
    property Minimum : Double read FMin write SetMin;
    property UnitStr : String read FUnit write FUnit;
    property Visible : Boolean read FVisible write FVisible;
    property AxisOrientation : TAxisOrientation
        read FAxisOrientation write FAxisOrientation;
  end;



Diese Klasse wird in einer Oszilloskop-Komponente benutzt. Wie man sieht, sind im Published-Teil Properties deklariert. Sie erscheinen aber nicht im Objektinspektor. Warum? Im Klasseninspektor sind sie aber sichtbar. Ein Fehler von Delphi oder übersehe ich etwas?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 10.08.06 11:30 
Also an einen Fehler von Delphi glaube ich nicht. Allerdings sehe ich so auf den ersten Blick auch keine Fehler in deinem Code. Deshalb werde ich das mal bei mir ausprobieren. Erstmal mit Delphi 2006. Oder hast du eine andere Version benutzt? Dann sags, damit ich es in der Version probieren kann.

Jedenfalls liegt ein solcher Fehler normalerqeise daran, dass nicht die neue Version der Komponente geladen wird. Wahrscheinlich hast du eine alte Version schonmal installiert gehabt als Komponente. Und wenn dann nicht korrekt neukompiliert oder instaliert wird, dann sieht man eben die Properties nicht. Dennoch sieht man sie im Klasseninspektor...
Mach mal folgendes:
Gehe in "Komponenten installieren..." rein. Dort entferne dein Package. Jetzt beende Delphi und lösche die kompilierte Package-Datei deines Pakcages. Dann starte Delphi neu. Jetzt öffne dein Package und drück auf Projekt erzeugen, damit alles neu kompiliert wird. Dann installiere das Package wieder.

Ich vermute, dass dann die Properties sichtbar sind...
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 10.08.06 11:31 
Triviale Frage: Hast du die Komponente schon installiert?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 10.08.06 11:33 
Davon bin ich mal ausgegangen...
Sonst hätte er die Komponente ja auch nicht im Objektinspektor gehabt um dort nach den Poperties zu suchen...
freedy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 10.08.06 11:34 
Hi.

Vielen Dank erstmal für die raschen Antworten. Ja, natürlich habe ich die Komponente auch richtig installiert. Mehrmals. Habe Sie sogar entfernt und neuinstalliert. Ohne Erfolg.
Als ich testweise mal ein Property aus der übergeordneten Komponentenklasse entfernt habe, hat das auch geklappt. Deshalb verstehe ich ja nicht, warum er jetzt hier meckert.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 10.08.06 11:43 
Also von der Deklaration her ist es auf jeden Fall korrekt...
Und mehr kann ich nur mit dem Source der Deklaration nicht sagen...
Ich habe bei mir ne neue Komponente erstellt und deinen Source eingesetzt. Und die Properties waren da. (Was anderes hatte ich auch nicht erwartet, die Deklaration sah schließlich korrekt aus, aber ich wollte sicher gehen.)
Das muss an etwas anderem liegen, aber um dazu was zu sagen bräuchte ich schon etwas Quelltext.
kotzekocher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Do 10.08.06 12:45 
Ganz einfach, die Komponente muss von TComponent und nicht von TObject abgeleitet werden. Dazu gibts ja überhaupt diese Klasse, weil dort Methoden drinstehen, um z.B. Properties in .dfm - Dateien zu speichern.

mfg
freedy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 10.08.06 13:33 
TComponent geht nicht, da ich keinen Parent zuweisen kann und darf.

Ich habe anstelle von TObject mal TPersistent genommen. Damit funzt es jetzt. Weshalb ich aber trotzdem noch nicht verstehe, warum bei Sebastian die Properties auch beim TObject aufgetaucht sind. Naja... egal. Es funzt, das zählt.

Falls jemand Interesse an einer Oszilloskop-Komponente hat, kann er sich ja bei mir melden. ;-)