Jump to content
PeterPanettone

Addon to hide single visual controls in Form-Designer?

Recommended Posts

Does anybody know a Delphi IDE addon that is able to selectively HIDE single visual controls (e.g. TPanel, etc.) at design-time in the Form-Designer? That would be very convenient when working with multiple NESTED overlapping container controls.

 

The IDE itself does not seem to have this feature.

Share this post


Link to post

Maybe that helps:

You can use the structure panel to access the hidden compenents you need.

If you really need to see and touch the hidden piece, then you better move from VCL to FMX, there you can set them invisible 🙂

 

Share this post


Link to post
29 minutes ago, Rollo62 said:

You can use the structure panel to access the hidden compenents you need.

It is not a question of accessing the hidden visual components. Of course, they can be accessed and selected in the Structure Panel (and thus shown and their properties edited in the Object Inspector), but their container content visually edited. Imagine you have a TPanel (Panel1) hidden behind another panel (Panel2) and want to insert and visually edit some other controls inside this hidden Panel1. In such a case it would be convenient temporarily hiding the Panel2 in the Form-Designer.

 

However, the question was about an addon having such a feature. Thank you for your observations.

Share this post


Link to post

The functionality to hide a subset of components in the Form-Designer is already existing: Show Non-Visual Components in the Edit menu. Could that functionality be used by an add-on to selectively hide a single control component (and its sub-controls)?

Share this post


Link to post

Hi...:classic_cool:

How about Frames? :classic_wink: Load the appropriate frame according to your requirements...

  • Like 1

Share this post


Link to post

We make extensive use of frames in VCL.

For FMX, it is not quite as clear cut...

Share this post


Link to post
Posted (edited)

Quick-And-Dirty ( complete package attached )

unit HideControls;

interface

procedure Register;

implementation

uses
  Vcl.Controls, DesignIntf, DesignEditors;

type
  THideControlsEditor = class(TComponentEditor)
  private
    procedure SetDesignVisible(Value: Boolean);
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure Register;
begin
  RegisterComponentEditor(TControl, THideControlsEditor);
end;

procedure THideControlsEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: SetDesignVisible(False);
    1: SetDesignVisible(True);
  end;
end;

function THideControlsEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Hide Control(s)';
    1: Result := 'Show Control(s)';
  else
    Result := '';
  end;
end;

function THideControlsEditor.GetVerbCount: Integer;
begin
  Result := 2;
end;

procedure THideControlsEditor.SetDesignVisible(Value: Boolean);
var
  I: Integer;
  list: IDesignerSelections;
begin
  list := CreateSelectionList;
  Designer.GetSelections(list);
  for I := 0 to list.Count - 1 do
    if list.Items[I] is TControl then
      TControl(list.Items[I]).SetDesignVisible(Value);
end;

end.

 

HideControlsAtDesignTimeDemo.zip

Edited by Uwe Raabe
wrong language
  • Like 3
  • Thanks 2

Share this post


Link to post
22 hours ago, Uwe Raabe said:

HideControlsAtDesignTimeDemo.zip

EXCELLENT piece of code! Thank you!

Share this post


Link to post

Well, that code is far from usable in production. F.i. you can still select that invisible control - at least if the space is not occupied by something else. I also get AVs when I unload that package.

Share this post


Link to post
52 minutes ago, Uwe Raabe said:

Well, that code is far from usable in production.

Well, I am sure the people at Embarcadero are able to do a bit more than Copy&Paste ...

Share this post


Link to post
59 minutes ago, Uwe Raabe said:

F.i. you can still select that invisible control

For me, this is not a drawback. It perfectly fits my purpose.

 

If you want, you could add a command "Show all hidden controls", because one might forget the different controls he has hidden.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×