Einzelnen Beitrag anzeigen

Udo

Registriert seit: 19. Jan 2003
54 Beiträge
 
Delphi 8 Architect
 
#4
  Alt 10. Feb 2003, 01:03
So funzt das doch nie.

Mal auf die Schnelle zum Weiterbasteln:

Delphi-Quellcode:
unit DBEditLabel;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Mask, DBCtrls;

type
  TDBEditLabel = class(TDBEdit)
  private
    FCaption: WideString;
    FLabel: TLabel;
    procedure SetLabelPosition;
    procedure SetCaption(Value: WideString);
  protected
    procedure SetParent(AParent: TWinControl); override;
    procedure SetName(const Value: TComponentName); override;
  public
    constructor Create(aOwner: TComponent); override;
    procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
  published
    property DBEditCaption: WideString read FCaption write SetCaption;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Zusätzlich', [TDBEditLabel]);
end;

{ TDBEditLabel }

constructor TDBEditLabel.Create(aOwner: TComponent);
begin
  inherited;
  FLabel := TLabel.Create(aOwner);
end;


procedure TDBEditLabel.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
  inherited SetBounds(ALeft, ATop, AWidth, AHeight);
  SetLabelPosition;
end;

procedure TDBEditLabel.SetCaption(Value: WideString);
begin
  if Value <> FCaption then
  begin
    FCaption := Value;
    FLabel.Caption := Value;
  end;
end;

procedure TDBEditLabel.SetLabelPosition;
begin
  if FLabel <> nil then
  begin
    FLabel.Top := Top - FLabel.Height - 5;
    FLabel.Left := Left + 5;
  end;
end;

procedure TDBEditLabel.SetName(const Value: TComponentName);
begin
  if (csDesigning in ComponentState) and ((FLabel.GetTextLen = 0) or
     (CompareText(FLabel.Caption, Name) = 0)) then
    FLabel.Caption := Value;
  inherited SetName(Value);
  if csDesigning in ComponentState then
    Text := '';
end;

procedure TDBEditLabel.SetParent(AParent: TWinControl);
begin
  inherited;
  FLabel.Parent := aParent;
end;

end.
Ein Fehler ist drin: Wenn man diese Komponente benutzt und die Appl startet kommt: EClassNotFound (TLabel).
Gibts ein Label im Form dieser Kompo gehts.
Jemand ne Idee was da flash ist?

Prost!
  Mit Zitat antworten Zitat