Autor Beitrag
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Do 31.10.02 14:13 
Hi!

Ich möchte mir eine Komponente schreiben, die aus zwei Komponenten besteht: Einem TPanel und einem TImage.

Bei Delphi 7 (auch schon bei Delphi 6) gibt es eine Komponente TLabeledEdit, also ein Editfeld mit einem Label. Ich hab mir das Mal im Sourcecode angeschaut, aber bin nicht draus schlau geworden wie das funzen soll. Mein Ergebnis war, dass ich zwar ein TImage als Unterkomponente vom TPanel hatte, aber mit dem TImage dann nix mehr anfangen konnte.

Has anybody some idea how to handle this?

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Do 31.10.02 14:23 
Oder anders gefragt:

Wie kann ich diese Komponente so schreiben, dass ich sie ohne Probleme in die Objekt-Palette von Delphi einbinden kann?

ausblenden volle Höhe 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:
46:
type
  TBubbleStone = class (TPanel)
  protected
    fForm, fColor: string;
    fImage: TImage;
    fIndex, fPoints: Integer;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Initialize(BallID: integer);
  published
    property BallForm: string read fForm write fForm;
    property BallColor: string read fColor write fColor;
    property BallPoints: integer read fPoints write fPoints;
    property Index: integer read fIndex write fIndex;
    property Image: TImage read fImage write fImage;
  end;
//--------------------------------------------------------------------

constructor TBubbleStone.Create;
begin
  inherited Create(AOwner);

  Height := 20;
  Width := 20;

  fImage := TImage.Create(AOwner);
  fImage.Parent := Self;
  fImage.Align := alClient;
end;

destructor TBubbleStone.Destroy;
begin
  inherited;
end;

procedure TBubbleStone.Initialize(BallID: integer);
const Colors: array[0..4] of string  = ('Blue','Red','Green','White','Orange');
      Points: array[0..4] of integer = (    80,  200,    150,    300,     500);

begin
  fImage.Picture.LoadFromFile('BITMAPS\Ball'+IntToStr(BallID)+'.bmp');
  fColor := Colors[BallID];
  fForm := 'Circle';
  fPoints := Points[BallID];
end;


Das Problem dabei ist bis jetzt, dass die Komponente TBubbleStone zwar aus zwei Komponenten besteht, aber jeder dieser Komponenten ist selbstständig. Ich möchte, dass TPanel und TImage eine einzige Komponente darstellen.

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?