Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Package compiliert nicht (https://www.delphipraxis.net/3781-package-compiliert-nicht.html)

Hansa 29. Mär 2003 18:06


Package compiliert nicht
 
Hi,

folgenden Code habe ich in ein Package einbauen wollen:

Code:
TDBLabeledEdit = class(TDBEdit)
  private
    { Private declarations }
    FDBfeldLabel : TLabel;
    procedure SetDBLabel (st : string);
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    { Published declarations }
    property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel;
  end;
Delphi stört sich an dem SetDBLabel. Aber warum ? Da steht nur folgendes drin:

Code:
procedure TDBLabeledEdit.SetDBLabel (st : string);
begin
  FDBfeldLabel.Caption := 'st';
end;
Fehlermeldung : "incompatible types"

Daniel B 29. Mär 2003 18:15

Re: Package compiliert nicht
 
Hallo Hansa,
Zitat:

Zitat von Hansa
Code:
  FDBfeldLabel.Caption := 'st';

Code:
  FDBfeldLabel.Caption := st;
Wäre vielleicht besser.

Grüsse, Daniel :hi:

mirage228 29. Mär 2003 18:16

muss das st nicht ohne die '' ?
Delphi-Quellcode:
procedure TDBLabeledEdit.SetDBLabel (st : string);
begin
  FDBfeldLabel.Caption := st; // ohne ''
end;

APP 29. Mär 2003 18:26

Hallo,

bin mir nicht sicher, aber hast Du im Objektinspektor
deiner Eigenschaft "DBfeldLabel" einen Label zugeordnet?

Könntest ja prüfen mit:
Delphi-Quellcode:
procedure TDBLabeledEdit.SetDBLabel (st : string);
IF Assigned(FDBfeldLabel) THEN
BEGIN
  FDBfeldLabel.Caption := st; // 'st'
END;
p.s.: ob 'st' oder st:String sollte keinen Fehler ausgeben, oder? (obwohl es nix bringt, 'st' zuzuweisen)

Hansa 29. Mär 2003 18:34

das Problem ist nicht das st, sondern daß nicht compiliert wird.

APP 29. Mär 2003 18:42

Hallo,
probier mal das:

Delphi-Quellcode:
procedure TDBLabeledEdit.SetDBLabel(Const st : TLabel);
IF Assigned(FDBfeldLabel) THEN
BEGIN
  FDBfeldLabel.Caption := st.Caption;
END;

Hansa 29. Mär 2003 18:50

nix.

Code:
property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel;
kommentiere ich das
Code:
write SetDBLabel
aus, wird compliliert. Also nicht die ganze Zeile.

Hansa 29. Mär 2003 19:09

Code:
procedure TDBLabeledEdit.SetDBLabel(st : TLabel);
begin
  FDBfeldLabel.Caption := st.Caption;
END;
Tatsächlich wird jetzt compiliert. Aber warum :?: Im OI ist von der Sache trotzdem nichts zu sehen.

APP 29. Mär 2003 19:20

Naja,
weil Du im
Delphi-Quellcode:
property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel;
DBfeldLabel als TLabel deklariert hast,
daher muß das Attribut
Delphi-Quellcode:
   FDBfeldLabel : TLabel;
und der Schreibzugriff
Delphi-Quellcode:
write SetDBLabel;
...
procedure TDBLabeledEdit.SetDBLabel(st : TLabel);
vom gleichem Typ sein.

Hansa 29. Mär 2003 19:29

Wo Du Recht hast, hast Du Recht. 8) 8) Jetzt wird compiliert. Da ist aber noch was : DBfeldLabel ist jetz im OI. Aber an Caption etc. vom Label komm ich nicht dran.


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:09 Uhr.
Seite 1 von 2  1 2      

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