Hidepanels组件

时间:2014-06-14 09:51:31

标签: delphi

我已经很久以前一直在使用这个组件(Q about THidepanels但成功了,但现在又没能使用这个代码了。

目前的失败是这样的:

- >每当我在THIDpanel上放置一个组件时,在DELPHI IDE设计视图中一切看起来都很好,但是一旦我尝试运行程序,放在我的hidepanel上的组件就不可见了。 在创建过程中,我要注意我的"放置组件的父级"在hidepanel上获取Workingpanel(较小的一个)作为父母......,我无法理解这种错误行为。

最新代码如下:

  ///
  /// a panel with a smaller panel inside  and a button on the side
  ///
  THidePanel = class(TPanel)
  private
    { Private-Deklarationen }
    ///
    /// a smaller working panel
    ///
    ///
    WorkingPanel: TPanel;
    FLargeHeight: Integer;
    FLargeWidth: Integer;
    FActivateButton: TButton;
    FExpandState: Boolean;
    FShrinkdirection: TShrinkdirection;
    FButtonPosition: TButtonPosition;
    FOnActivateBtnClick: TNotifyEvent;
    FHasCustomSize: Boolean;
    procedure SetButtonPosition(const Value: TButtonPosition);
    procedure SetShrinkdirection(const Value: TShrinkdirection);
    procedure ResizeUsedComponents;
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor create(aOwner: TComponent); override;
    procedure WMSize(var Msg: TWMSize); message WM_SIZE;
    procedure HideComponents;
    procedure H_ActivateButtonClick(Sender: TObject);
    procedure SetState(astate: Boolean);
    procedure free;
    destructor destroy; override;
  published
    { Published-Deklarationen }
property OnActivateButtonClick: TNotifyEvent read FOnActivateBtnClick
      write FOnActivateBtnClick;
    property ButtonPosition: TButtonPosition read FButtonPosition
      write SetButtonPosition;
    property Shrinkdirection: TShrinkdirection read FShrinkdirection
      write SetShrinkdirection;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [THidePanel]);
end;

{ THidePanel }

constructor THidePanel.create(aOwner: TComponent);
begin
  inherited;
  padding.Left:= BorderSize;
  padding.top:= BorderSize;
  padding.right:= BorderSize;
  padding.Bottom:= BorderSize;
  //  the inner panel
  WorkingPanel := TPanel.create(self);
  WorkingPanel.Caption := 'WORKIN PANEL FOR TEST / DEBUG ONLY';
  WorkingPanel.BevelOuter := bvNone;
  // WorkingPanel.BringToFront;
  WorkingPanel.Color :=220;
  WorkingPanel.ParentColor := false;
  WorkingPanel.Visible := true;
  WorkingPanel.Parent := self;
  WorkingPanel.Align := alClient;
  WorkingPanel.ParentBackGround := false;
  //  the button to mimimize / maximize
  FActivateButton := TButton.create(self);
  FActivateButton.Parent := self;
  FActivateButton.Caption := '<';
  FActivateButton.OnClick := H_ActivateButtonClick;
  FActivateButton.Width := BorderSize;
  FActivateButton.Height := BorderSize;
  ///   the restore values , correct setting
  FLargeWidth := self.Width;
  FLargeHeight := self.Height;
  FHasCustomSize := false;
  SetButtonPosition(topright);
  //  drop components only on the inner panel
  ControlStyle := ControlStyle - [csAcceptsControls]
end

0 个答案:

没有答案