Autor Beitrag
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Fr 04.04.03 10:52 
Hi,

seit Delphi 6 gibt es ja die Komponente LabeledEdit. So etwas ähnliches wollte ich nun mit einem DBedit machen. Und zwar so :

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:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
unit DBLabeledEdit;

interface

uses
  Windows, Dialogs, Messages, SysUtils, Classes, Controls, StdCtrls, Mask, DBCtrls;

type
  TDBLabeledEdit = class(TDBEdit)
  private
    { Private declarations }
    FLabel : TLabel;
  protected
    { Protected declarations }
  public
    { Public declarations }
    procedure SetDBLabel (p : TLabel);
  public
    { Public declarations }
    constructor Create (AOwner : TComponent); override;
    destructor Destroy; override;
  published
    { Published declarations }
    property MyDBLabel: TLabel read FLabel write SetDBLabel;
  end;

procedure Register;

implementation

constructor TDBlabeledEdit.Create (AOwner : TComponent);
  begin
    inherited Create (AOwner);
    FLabel := TLabel.Create(AOwner);
    FLabel.Caption := 'CAPTION';
  end;

destructor TDBLabeledEdit.Destroy;
  begin
    FLabel.Destroy;
    inherited;
  end;

procedure TDBLabeledEdit.SetDBLabel (p : TLabel);
  begin
showmessage ('JKLJLJL');
    FLabel.Caption := 'HJHJJH';
invalidate;
//    FLabel.SetSubComponent(true);
  end;

procedure Register;
begin
  RegisterComponents('Data Controls', [TDBLabeledEdit]);
end;

end.


Das ganze habe ich dann in ein Package verfrachtet und installiert. Jetzt gibt es zwei Sachen, die ich nicht ganz verstehe :

1. Lasse ich ein Programm laufen, auf dem sich die Komponente befindet, kommt Exception "classTLabel not found"

2. Obwohl sich das MyDBLabel im OI befindet und ich darüber Zugriff auf alles habe, sieht man nichts auf dem Bildschirm. Im Create habe ich testweise die Caption des Labels auf 'CAPTION' gesetzt. Auch das sieht man schön im OI. Ansonsten ist das Label aber unsichtbar.

Und noch etwas wichtiges : Die Prozedur SetDBLabel wird nicht erreicht.

_________________
Gruß
Hansa
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 15.04.03 12:19 
weiß keiner was dazu zu sagen :?:

_________________
Gruß
Hansa
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 15.04.03 12:39 
Hi,

du hast den Parent vom Label vergessen... ;)
ausblenden Quelltext
1:
Label.Parent:=Owner;					


Wenn das mit der Fehlermeldung daran nicht gelegen hat, wird es wahrscheinlich daran liegen das die Unit in der das TLabel drin ist, nochnicht in dein Projekt eingebunden ist, in dem moment wo du das Edit auf das Form klickst = er findet die klasse TLabel nicht = Error... ;)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 15.04.03 12:48 
meinst Du so was ?

ausblenden Quelltext
1:
2:
  FLabel := TLabel.Create(AOwner);
  FLabel.Parent := AOwner;


das sind aber inkompatible Typen. TWinControl und TComponent, sagt zumindest Delphi.

_________________
Gruß
Hansa
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 15.04.03 14:11 
@Hansa: das hatten wir doch schon mal! ;)
Wenn du mich per ICQ daran erinnerst, dann schau ich zu Hause mal ob ich was find. Momentan kann ich aber gar nix machn da ích nur an meinem Zivi-Arbeitsplatz hab und ergo natürlich auch kein Delphi o.ä.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 24.04.03 12:21 
ich habe das jetzt mal anders rum gemacht, abgeleitet von TLabeledEdit. An die DBfelder und das Label komme ich einwandfrei ran, aber das Blöde ist nun, daß ich in dem Editfeld keine Daten sehe. Dabei bin ich ziemlich genau nach Delphi-Handbuch vorgegangen. Vielleicht sieht ja irgendwer, wo der Fehler liegt. 8)

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:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
unit DBLabeledEdit;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, StdCtrls, ExtCtrls,
  Dialogs, DB, DBCtrls;

procedure Register;

type
  TDBLabeledEdit = class(TLabeledEdit)
  private
    { Private declarations }
    FDataLink: TFieldDataLink;
    function GetDataField: string;
    function GetDataSource: TDataSource;
    procedure SetDataField(const Value: string);
    procedure SetDataSource(Value: TDataSource);
  protected
    { Protected declarations }
    procedure DataChange (Sender: TObject);
    procedure UpdateData (Sender : TObject);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    { Published declarations }
    property DataSource : TDataSource read GetDataSource write SetDataSource;
    property DataField : string read GetDataField write SetDataField;
  end;


implementation

constructor TDBLabeledEdit.Create (AOwner : TComponent);
begin
  inherited Create (AOwner);
  LabelPosition := lpLeft;
  FDataLink := TFieldDataLink.Create;
  FDataLink.OnDataChange := DataChange;
  FDataLink.OnUpdateData := UpdateData;
end;

destructor TDBLabeledEdit.Destroy;
begin
  FDataLink.Free;
  inherited Destroy;
end;

function TDBLabeledEdit.GetDataField : string;
begin
  Result := FDataLink.FieldName;
end;

function TDBLabeledEdit.GetDataSource : TDataSource;
begin
  GetDataSource := FDataLink.DataSource;
end;

procedure TDBLabeledEdit.SetDataField(const Value: string);
begin
  FDataLink.FieldName := Value;
end;

procedure TDBLabeledEdit.SetDataSource(Value: TDataSource);
begin
  FDataLink.DataSource := Value;
end;

procedure TDBLabeledEdit.DataChange;
begin
  FDataLink.Modified;
  inherited Change;
end;

procedure TDBLabeledEdit.UpdateData(Sender: TObject);
begin
  FDataLink.Field.AsString := 'jkljkkljjl`';
end;

procedure Register;
begin
  RegisterComponents('Data Controls', [TDBLabeledEdit]);
end;

end.

_________________
Gruß
Hansa