Autor Beitrag
Hagbard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Do 03.06.04 11:43 
Hallo, das hier ist der Code einer eigenen Komponente. Ich möchte bestimmte Werte Standardmäßig setzen, damit alle Buttons (in diesem Fall) gleich aussehn.

Wenn Ich diese Komponente aber installiere, hat Sie die gleichen Eigenschaften wie die Original SpeedButton Komponente! Kann mir jemand sagen woran das liegt, bzw. was Ich falsch gemacht habe???

Viele Grüße,
Christian

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:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
unit TiDolphinButton;

interface

uses
  SysUtils, Classes, Controls, Buttons, Graphics;

type
  TTiDolphinButton = class(TSpeedButton)
  private
    procedure SetFontBold(const Value: Boolean);
    { Private-Deklarationen }
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }

    constructor Create(AOwner : TWinControl);
    destructor Destroy; override;

  published
    { Published-Deklarationen }

    property Bold : Boolean write SetFontBold;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Dolphin', [TTiDolphinButton]);
end;

{ TTiDolphinButton }

constructor TTiDolphinButton.Create(AOwner: TWinControl);
begin
  inherited create(AOwner);

    // Standard Size of the Button
    self.Width := 96;
    self.Height := 33;

    self.Font.Name := 'Arial';
    self.Font.Size := 12;
end;

destructor TTiDolphinButton.Destroy;
begin

  inherited;
end;

procedure TTiDolphinButton.SetFontBold(const Value: Boolean);
begin
 if Value then
  self.Font.Style := [fsBold]
 else
  self.Font.Style := [];
end;

end.



Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt.

_________________
I haven't failed, I just found 10,000 ways that won't work!
iGoA
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 103

Alle Win´s
D5 Prof
BeitragVerfasst: Do 03.06.04 12:50 
Ich hatte mal ein ähnliches Problem. Mir lag es daran, daß der Konstruktor nicht neu aufgerufen wurde, nur weil ich die Komponente kompiliere oder auch neu installiere. Man muss auch die Komponente erneut ins Form einfügen.

_________________
"Diner for One" objektorientiert:
"The same method as last year, Ms. Sophie?" (was für´n Schwachsinn)
Hagbard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Do 03.06.04 14:19 
Die Komponente habe Ich jedes mal gelöscht und eine neue in die Form aufgenommen...

Es scheint fast so, als würde er den Constructor nicht aufrufen...

_________________
I haven't failed, I just found 10,000 ways that won't work!
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Do 03.06.04 16:37 
Hagbard hat folgendes geschrieben:
...
Es scheint fast so, als würde er den Constructor nicht aufrufen...


Kann ja auch garnicht! Woher soll die VCL deinen construktor den kennen? Du musst schon 'overriden' damit sie ein chance hat, über die existenz von deinem create bescheid zu wissen:

ausblenden Delphi-Quelltext
1:
2:
    constructor Create(AOwner : TWinControl); override;
    destructor Destroy; override;


Und bist du dir sicher, dass es write-only properties gibt??
ausblenden Delphi-Quelltext
1:
2:
3:
  published 
    { Published-Deklarationen } 
   property Bold : Boolean write SetFontBold; <--  :?:


bis denn!

_________________
mfg.
mâximôv
Hagbard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Di 08.06.04 13:15 
Hi und danke schonmal,
aber wie kann Ich den Create overriden?

Bei diesem Code, bekomme Ich immer die Fehlermeldung: Unbekannte Anweisung: 'override'

ausblenden Quelltext
1:
2:
3:
    { Public-Deklarationen }
    constructor Create(AOwner : TWinControl); override;
    destructor Destroy; override;


was hab ich falsch gemacht / vergessen??

Gruß,
Christian

_________________
I haven't failed, I just found 10,000 ways that won't work!
Hagbard Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Di 08.06.04 15:57 
Ich hab den Fehler gefunden....

es darf kein TWinControl sein, sonder ein TObject.....

_________________
I haven't failed, I just found 10,000 ways that won't work!