1

I had alredy been using this component ( Q about THidepanels a long time ago with success, but failed to use this code now again.

The current failure goes like this :

--> whenever I place a component on the THidpanel, in the DELPHI IDE design view everything Looks fine, but once I try to run the program, the compoents placed on my hidepanel are not visible. In the create procedure I take care that the parent of my "placed component" on the hidepanel gets the Workingpanel (the smaller one ) as a parent .... , I can not understand that wrong behaviour.

Latest Code goes like this :

  ///
  /// 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
Community
  • 1
  • 1
Franz
  • 1,883
  • 26
  • 47
  • BorderSize isn't 0, is it? – Sertac Akyuz Jun 14 '14 at 13:41
  • If I'm not mistaken you should call .SetSubComponent(True) on the components inside the panel. But have a look [here](http://stackoverflow.com/questions/9479872/component-creation-joining-components-together), since it actually answers many of the component with subcomponents questions. – Gustavo Carreno Sep 24 '14 at 01:39

0 Answers0