因为我对组件不是很熟悉,D7是这么定义的
 { TLabeledEdit }  TLabeledEdit = class(TCustomLabeledEdit)
  published
    property Anchors;
    property AutoSelect;
    property AutoSize;
    property BevelEdges;
    property BevelInner;
    property BevelKind;
    property BevelOuter;
    property BiDiMode;
    property BorderStyle;
    property CharCase;
    property Color;
    property Constraints;
    property Ctl3D;
    property DragCursor;
    property DragKind;
    property DragMode;
    property EditLabel;
    property Enabled;
    property Font;
    property HideSelection;
    property ImeMode;
    property ImeName;
    property LabelPosition default lpAbove;
    property LabelSpacing default 3;
    property MaxLength;
    property OEMConvert;
    property ParentBiDiMode;
    property ParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PasswordChar;
    property PopupMenu;
    property ReadOnly;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Text;
    property Visible;
    property OnChange;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDock;
    property OnStartDrag;
  end;

解决方案 »

  1.   

    放到DELPHI5下編譯安裝,出錯改吧。這樣子看不出什麼來。
    這裏只是父類的PublishED 部分的。
      

  2.   

    unit D7LabelEdit
    {$S-,W-,R-,H+,X+}
    {$C PRELOAD}interface{$IFDEF LINUX}
    uses Messages, WinUtils, Windows, SysUtils, Classes,
      Controls, Forms, Menus, Graphics, StdCtrls;
    {$ENDIF}
    {$IFDEF MSWINDOWS}
    uses Messages, Windows, SysUtils, Classes,
      Controls, Forms, Menus, Graphics, StdCtrls;
    {$ENDIF}type  TCustomLabeledEdit = class(TCustomEdit)
      private
        FEditLabel: TBoundLabel;
        FLabelPosition: TLabelPosition;
        FLabelSpacing: Integer;
        procedure SetLabelPosition(const Value: TLabelPosition);
        procedure SetLabelSpacing(const Value: Integer);
      protected
        procedure SetParent(AParent: TWinControl); override;
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;
        procedure SetName(const Value: TComponentName); override;
        procedure CMVisiblechanged(var Message: TMessage);
          message CM_VISIBLECHANGED;
        procedure CMEnabledchanged(var Message: TMessage);
          message CM_ENABLEDCHANGED;
        procedure CMBidimodechanged(var Message: TMessage);
          message CM_BIDIMODECHANGED;
      public
        { Public declarations }
        constructor Create(AOwner: TComponent); override;
        procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
        procedure SetupInternalLabel;
        property EditLabel: TBoundLabel read FEditLabel;
        property LabelPosition: TLabelPosition read FLabelPosition write SetLabelPosition;
        property LabelSpacing: Integer read FLabelSpacing write SetLabelSpacing;
      end;  { TLabeledEdit }  TLabeledEdit = class(TCustomLabeledEdit)
      published
        property Anchors;
        property AutoSelect;
        property AutoSize;
        property BevelEdges;
        property BevelInner;
        property BevelKind;
        property BevelOuter;
        property BiDiMode;
        property BorderStyle;
        property CharCase;
        property Color;
        property Constraints;
        property Ctl3D;
        property DragCursor;
        property DragKind;
        property DragMode;
        property EditLabel;
        property Enabled;
        property Font;
        property HideSelection;
        property ImeMode;
        property ImeName;
        property LabelPosition default lpAbove;
        property LabelSpacing default 3;
        property MaxLength;
        property OEMConvert;
        property ParentBiDiMode;
        property ParentColor;
        property ParentCtl3D;
        property ParentFont;
        property ParentShowHint;
        property PasswordChar;
        property PopupMenu;
        property ReadOnly;
        property ShowHint;
        property TabOrder;
        property TabStop;
        property Text;
        property Visible;
        property OnChange;
        property OnClick;
        property OnContextPopup;
        property OnDblClick;
        property OnDragDrop;
        property OnDragOver;
        property OnEndDock;
        property OnEndDrag;
        property OnEnter;
        property OnExit;
        property OnKeyDown;
        property OnKeyPress;
        property OnKeyUp;
        property OnMouseDown;
        property OnMouseMove;
        property OnMouseUp;
        property OnStartDock;
        property OnStartDrag;
      end;
      procedure register;implementationprocedure register;
    begin
      RegisterComponents('D7LabelEdit', [TLabeledEdit]);
    end;{ TCustomLabeledEdit }constructor TCustomLabeledEdit.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      FLabelPosition := lpAbove;
      FLabelSpacing := 3;
      SetupInternalLabel;
    end;procedure TCustomLabeledEdit.CMBidimodechanged(var Message: TMessage);
    begin
      inherited;
      FEditLabel.BiDiMode := BiDiMode;
    end;procedure TCustomLabeledEdit.CMEnabledchanged(var Message: TMessage);
    begin
      inherited;
      FEditLabel.Enabled := Enabled;
    end;procedure TCustomLabeledEdit.CMVisiblechanged(var Message: TMessage);
    begin
      inherited;
      FEditLabel.Visible := Visible;
    end;procedure TCustomLabeledEdit.Notification(AComponent: TComponent;
      Operation: TOperation);
    begin
      inherited Notification(AComponent, Operation);
      if (AComponent = FEditLabel) and (Operation = opRemove) then
        FEditLabel := nil;
    end;procedure TCustomLabeledEdit.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
    begin
      inherited SetBounds(ALeft, ATop, AWidth, AHeight);
      SetLabelPosition(FLabelPosition);
    end;procedure TCustomLabeledEdit.SetLabelPosition(const Value: TLabelPosition);
    var
      P: TPoint;
    begin
      if FEditLabel = nil then exit;
      FLabelPosition := Value;
      case Value of
        lpAbove: P := Point(Left, Top - FEditLabel.Height - FLabelSpacing);
        lpBelow: P := Point(Left, Top + Height + FLabelSpacing);
        lpLeft : P := Point(Left - FEditLabel.Width - FLabelSpacing,
                        Top + ((Height - FEditLabel.Height) div 2));
        lpRight: P := Point(Left + Width + FLabelSpacing,
                        Top + ((Height - FEditLabel.Height) div 2));
      end;
      FEditLabel.SetBounds(P.x, P.y, FEditLabel.Width, FEditLabel.Height);
    end;procedure TCustomLabeledEdit.SetLabelSpacing(const Value: Integer);
    begin
      FLabelSpacing := Value;
      SetLabelPosition(FLabelPosition);
    end;procedure TCustomLabeledEdit.SetName(const Value: TComponentName);
    begin
      if (csDesigning in ComponentState) and ((FEditlabel.GetTextLen = 0) or
         (CompareText(FEditLabel.Caption, Name) = 0)) then
        FEditLabel.Caption := Value;
      inherited SetName(Value);
      if csDesigning in ComponentState then
        Text := '';
    end;procedure TCustomLabeledEdit.SetParent(AParent: TWinControl);
    begin
      inherited SetParent(AParent);
      if FEditLabel = nil then exit;
      FEditLabel.Parent := AParent;
      FEditLabel.Visible := True;
    end;procedure TCustomLabeledEdit.SetupInternalLabel;
    begin
      if Assigned(FEditLabel) then exit;
      FEditLabel := TBoundLabel.Create(Self);
      FEditLabel.FreeNotification(Self);
      FEditLabel.FocusControl := Self;
    end;自己试试看吧!
      

  3.   


    DELPHI说错误太多[Error] LabeledEdit.pas(18): Undeclared identifier: 'TCustomEdit'
    [Error] LabeledEdit.pas(18): Class type required
    [Error] LabeledEdit.pas(20): Undeclared identifier: 'TBoundLabel'
    [Error] LabeledEdit.pas(21): Undeclared identifier: 'TLabelPosition'
    [Error] LabeledEdit.pas(26): Undeclared identifier: 'TWinControl'
    [Error] LabeledEdit.pas(27): Undeclared identifier: 'TComponent'
    [Error] LabeledEdit.pas(27): Undeclared identifier: 'TOperation'
    [Error] LabeledEdit.pas(28): Undeclared identifier: 'TComponentName'
    [Error] LabeledEdit.pas(29): Undeclared identifier: 'TMessage'
    [Error] LabeledEdit.pas(30): Undeclared identifier: 'CM_VISIBLECHANGED'
    [Error] LabeledEdit.pas(30): Illegal message method index
    [Error] LabeledEdit.pas(32): Undeclared identifier: 'CM_ENABLEDCHANGED'
    [Error] LabeledEdit.pas(32): Illegal message method index
    [Error] LabeledEdit.pas(34): Undeclared identifier: 'CM_BIDIMODECHANGED'
    [Error] LabeledEdit.pas(34): Illegal message method index
    [Error] LabeledEdit.pas(37): Cannot override a static method
    [Error] LabeledEdit.pas(38): Method 'SetBounds' not found in base class
    [Error] LabeledEdit.pas(49): Property 'Anchors' does not exist in base class
    [Error] LabeledEdit.pas(50): Property 'AutoSelect' does not exist in base class
    [Error] LabeledEdit.pas(51): Property 'AutoSize' does not exist in base class
    [Error] LabeledEdit.pas(52): Property 'BevelEdges' does not exist in base class
    [Error] LabeledEdit.pas(53): Property 'BevelInner' does not exist in base class
    [Error] LabeledEdit.pas(54): Property 'BevelKind' does not exist in base class
    [Error] LabeledEdit.pas(55): Property 'BevelOuter' does not exist in base class
    [Error] LabeledEdit.pas(56): Property 'BiDiMode' does not exist in base class
    [Error] LabeledEdit.pas(57): Property 'BorderStyle' does not exist in base class
    [Error] LabeledEdit.pas(58): Property 'CharCase' does not exist in base class
    [Error] LabeledEdit.pas(59): Property 'Color' does not exist in base class
    [Error] LabeledEdit.pas(60): Property 'Constraints' does not exist in base class
    [Error] LabeledEdit.pas(61): Property 'Ctl3D' does not exist in base class
    [Error] LabeledEdit.pas(62): Property 'DragCursor' does not exist in base class
    [Error] LabeledEdit.pas(63): Property 'DragKind' does not exist in base class
    [Error] LabeledEdit.pas(64): Property 'DragMode' does not exist in base class
    [Error] LabeledEdit.pas(66): Property 'Enabled' does not exist in base class
    [Error] LabeledEdit.pas(67): Property 'Font' does not exist in base class
    [Error] LabeledEdit.pas(68): Property 'HideSelection' does not exist in base class
    [Error] LabeledEdit.pas(69): Property 'ImeMode' does not exist in base class
    [Error] LabeledEdit.pas(70): Property 'ImeName' does not exist in base class
    [Error] LabeledEdit.pas(71): Undeclared identifier: 'lpAbove'
    [Error] LabeledEdit.pas(73): Property 'MaxLength' does not exist in base class
    [Error] LabeledEdit.pas(74): Property 'OEMConvert' does not exist in base class
    [Error] LabeledEdit.pas(75): Property 'ParentBiDiMode' does not exist in base class
    [Error] LabeledEdit.pas(76): Property 'ParentColor' does not exist in base class
    [Error] LabeledEdit.pas(77): Property 'ParentCtl3D' does not exist in base class
    [Error] LabeledEdit.pas(78): Property 'ParentFont' does not exist in base class
    [Error] LabeledEdit.pas(79): Property 'ParentShowHint' does not exist in base class
    [Error] LabeledEdit.pas(80): Property 'PasswordChar' does not exist in base class
    [Error] LabeledEdit.pas(81): Property 'PopupMenu' does not exist in base class
    [Error] LabeledEdit.pas(82): Property 'ReadOnly' does not exist in base class
    [Error] LabeledEdit.pas(83): Property 'ShowHint' does not exist in base class
    [Error] LabeledEdit.pas(84): Property 'TabOrder' does not exist in base class
    [Error] LabeledEdit.pas(85): Property 'TabStop' does not exist in base class
    [Error] LabeledEdit.pas(86): Property 'Text' does not exist in base class
    [Error] LabeledEdit.pas(87): Property 'Visible' does not exist in base class
    [Error] LabeledEdit.pas(88): Property 'OnChange' does not exist in base class
    [Error] LabeledEdit.pas(89): Property 'OnClick' does not exist in base class
    [Error] LabeledEdit.pas(90): Property 'OnContextPopup' does not exist in base class
    [Error] LabeledEdit.pas(91): Property 'OnDblClick' does not exist in base class
    [Error] LabeledEdit.pas(92): Property 'OnDragDrop' does not exist in base class
    [Error] LabeledEdit.pas(93): Property 'OnDragOver' does not exist in base class
    [Error] LabeledEdit.pas(94): Property 'OnEndDock' does not exist in base class
    [Error] LabeledEdit.pas(95): Property 'OnEndDrag' does not exist in base class
    [Error] LabeledEdit.pas(96): Property 'OnEnter' does not exist in base class
    [Error] LabeledEdit.pas(97): Property 'OnExit' does not exist in base class
    [Error] LabeledEdit.pas(98): Property 'OnKeyDown' does not exist in base class
    [Error] LabeledEdit.pas(99): Property 'OnKeyPress' does not exist in base class
    [Error] LabeledEdit.pas(100): Property 'OnKeyUp' does not exist in base class
    [Error] LabeledEdit.pas(101): Property 'OnMouseDown' does not exist in base class
    [Error] LabeledEdit.pas(102): Property 'OnMouseMove' does not exist in base class
    [Error] LabeledEdit.pas(103): Property 'OnMouseUp' does not exist in base class
    [Error] LabeledEdit.pas(104): Property 'OnStartDock' does not exist in base class
    [Error] LabeledEdit.pas(105): Property 'OnStartDrag' does not exist in base class
    [Error] LabeledEdit.pas(113): Undeclared identifier: 'RegisterComponents'
    [Error] LabeledEdit.pas(113): Ordinal type required
    [Error] LabeledEdit.pas(120): Too many actual parameters
    [Error] LabeledEdit.pas(129): Missing operator or semicolon
    [Error] LabeledEdit.pas(135): Missing operator or semicolon
    [Error] LabeledEdit.pas(141): Missing operator or semicolon
    [Error] LabeledEdit.pas(147): Undeclared identifier: 'Notification'
    [Warning] LabeledEdit.pas(148): Comparing signed and unsigned types - widened both operands
    [Error] LabeledEdit.pas(148): Undeclared identifier: 'opRemove'
    [Error] LabeledEdit.pas(154): Undeclared identifier: 'SetBounds'
    [Error] LabeledEdit.pas(160): Undeclared identifier: 'TPoint'
    [Error] LabeledEdit.pas(162): Operator not applicable to this operand type
    [Error] LabeledEdit.pas(165): Undeclared identifier: 'Point'
    [Error] LabeledEdit.pas(165): Undeclared identifier: 'Top'
    [Error] LabeledEdit.pas(165): Missing operator or semicolon
    [Error] LabeledEdit.pas(165): Statement expected, but expression of type 'Integer' found
    [Error] LabeledEdit.pas(172): Declaration expected but identifier 'FEditLabel' found
    [Fatal Error] LabeledEdit.pas(173): Compilation terminated; too many errors