Einzelnen Beitrag anzeigen

Benutzerbild von Leuselator
Leuselator

Registriert seit: 18. Mär 2003
Ort: Berlin
589 Beiträge
 
Delphi 8 Architect
 
#2

Re: Unterproperty in Objektinstpektor

  Alt 2. Sep 2003, 12:49
z.B.:

Delphi-Quellcode:
type
  TMyComponent = class(TWinControl)
  private
    FVisible,
    FStayOnTop,
    FPopUp,
    FFlashing : Boolean;
  protected
    procedure SetValue(index : Integer; Value : Boolean);
  public

  published
    property Visible : Boolean index 0 read FVisible write SetValue;
    property StayOnTop : Boolean index 1 read FStayOnTop write SetValue;
    property PopUp : Boolean index 2 read FPopUp write SetValue;
    property Flashing : Boolean index 3 read FFlashing write SetValue;
  end;

implementation

procedure TMyComponent.SetValue(index : Integer; Value : Boolean);
begin
  case index of
    0: FVisible := Value;
    1: FStayOnTop := Value;
    2: FPopUp := Value;
    3: FFlashing := Value;
  end;
end;
oder:

Delphi-Quellcode:
type
  TShowMode = (smVisible,smStayOnTop,smPopUp,smFlashing);
  TShowModeSet = set of TShowMode;

  TMyComponent = class(TWinControl)
  private
    FShowMode : TShowModeSet;

    FVisible,
    FStayOnTop,
    FPopUp,
    FFlashing : Boolean;
  protected
    procedure SetValue(Value : TShowModeSet);
  public
    property Visible : Boolean read FVisible ;
    property StayOnTop : Boolean read FStayOnTop;
    property PopUp : Boolean read FPopUp ;
    property Flashing : Boolean read FFlashing ;
  published
    property ShowMode : TShowModeSet read FShowMode write SetValue;
  end;

implementation

procedure TMyComponent.SetValue(Value: TShowModeSet);
begin
    FShowMode := Value;
    FStayOnTop := (smVisible in FShowMode);
    FFlash := (smStayOnTop in FShowMode);
    FPopUp := (smPopUp in FShowMode);
    FFlashing := (smFlashing in FShowMode);
end;

Gruß
Tim Leuschner
  Mit Zitat antworten Zitat