Autor Beitrag
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 13.10.02 19:57 
Hi,

Ich benutze bei meiner Komponente mehrere Farben die z.Z. noch alle wild durcheinander im ObjectInspector stehen...

Weiß jemand wie ich es so machen kann, wie es z.B. bei einem Form mit den "Constraints" gemacht ist??
Also einen Oberpunkt "Colors", und wenn man auf das Plus davor klickt, öffnen sich alle Farben die man ändern kann :) (So wie bei Constraints halt, nur mit TColor anstatt Integer)

Au'revoir,
Aya
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 13.10.02 22:41 
Hi,

schau doch einfach mal in den Quelltext (falls vorhanden). Hier mal ein Auszug wie TSizeConstraints definiert ist:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Type
  TSizeConstraints = class(TPersistent)
  private
    FControl: TControl;
    FMaxHeight: TConstraintSize;
    FMaxWidth: TConstraintSize;
    FMinHeight: TConstraintSize;
    FMinWidth: TConstraintSize;
    FOnChange: TNotifyEvent;
    procedure SetConstraints(Index: Integer; Value: TConstraintSize);
  protected
    procedure Change; dynamic;
    procedure AssignTo(Dest: TPersistent); override;
    property Control: TControl read FControl;
  public
    constructor Create(Control: TControl); virtual;
    property OnChange: TNotifyEvent read FOnChange write FOnChange;
  published
    property MaxHeight: TConstraintSize index 0 read FMaxHeight write SetConstraints default 0;
    property MaxWidth: TConstraintSize index 1 read FMaxWidth write SetConstraints default 0;
    property MinHeight: TConstraintSize index 2 read FMinHeight write SetConstraints default 0;
    property MinWidth: TConstraintSize index 3 read FMinWidth write SetConstraints default 0;
  end;

Jetzt brauchst Du es nur noch überarbeiten. Also statt den Integer-Werten Color Eingeschaften einfügen usw. Die Implementation von tSizeConstraints findest Du in der Unit Controls.pas.

Gruß
TINO
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 13.10.02 23:43 
Hi,

das hatte ich auchschon gesehen, aber irgendwie klappt's bei mir net... wenn ich auf das "+" klicke kommen keine weiteren attribute...

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  TColors = class(TPersistent)
  private
    fCol1: TColor;
    fCol2: TColor;
    fCol3: TColor;
    fCol4: TColor;
  protected
  public
  published
    property Color1: TColor index 0 read fCol1 write fCol1 Default clBlack;
    property Color2: TColor index 1 read fCol2 write fCol2 Default clBlack;
    property Color3: TColor index 2 read fCol3 write fCol3 Default clBlack;
    property Color4: TColor index 3 read fCol4 write fCol4 Default clBlack;
  end;


Au'revoir,
Aya
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 14.10.02 08:52 
Hallo,

als erstes solltest Du den Index-Teil rausnehmen. Macht in Deinem Fall keinen Sinn da Du für jedes Property eine eigene Variable benutzt. Also so:
ausblenden Quelltext
1:
2:
3:
4:
5:
published
  property Color1: TColor read fCol1 write fCol1 Default clBlack;
  property Color2: TColor read fCol2 write fCol2 Default clBlack;
  property Color3: TColor read fCol3 write fCol3 Default clBlack;
  property Color4: TColor read fCol4 write fCol4 Default clBlack;

Dann würde ich erstmal die Assign Methode implementieren. Für die Anzeige im OI ist das glaube ich nicht notwendig aber wenn Du Deine Komponente veröffentlichen solltest sollte so ein Property wie tColors auch über so eine Methode verfügen.

Hast Du das Property in Deiner Komponenten im Constructor auch erstellt?

Gruß
TINO