【问题标题】:Delphi XE4 IDE, how to always hide the bottom panes of the Object InspectorDelphi XE4 IDE,如何始终隐藏对象检查器的底部窗格
【发布时间】:2017-01-06 07:59:32
【问题描述】:

Obeject Inspector 底部的两个窗格完全没有用,而且它不必要地占用了屏幕空间,如下面的屏幕截图所示。即使在重新启动 IDE 后如何禁用这两个窗格?内置选项或第三方插件对我来说没问题。谢谢。

【问题讨论】:

  • 你可以写一个插件来隐藏面板。
  • 这些看起来都像是 GExperts IDE 子菜单中的条目。您是否查看过它是否具有对象检查器的配置选项?另外,右键单击并在Show 中取消选中Quick Action Panel
  • @DavidHeffernan 如果可能的话,这将是最后的选择。
  • @MartynA,刚刚检查了 GExpert 配置,没有找到这样的选项。但是,我发现了一个新的 GExperts 功能 - 'Go To' 对话框增强功能,非常方便:D
  • @EdwinYip 如果您错过了更多 GExperts 功能:我已在此处记录了我的补充:blog.dummzeuch.de/gexperts-documentation

标签: delphi delphi-xe4 delphi-ide


【解决方案1】:

下面的 XE4 代码显示了如何隐藏要删除的项目:它们是实例 THotCommandsTDescriptionPane 的类。

更新这个答案的原始版本需要一个包,包括一个插件表单和一个按钮来刷新对象检查器以隐藏这两个 不需要的物品。在下面的代码中,我完全删除了表单,项目的隐藏现在应该是全自动的。为了实现这一点,我用DesignNotification 对象替换了以前的 IDENotifier 并使用它的 SelectionChanged 事件调用隐藏THotCommandsTDescriptionPane 控件的代码。 TDesignNotification 在 DesignIntf​​.Pas 中实现 IDesignNotification 接口

另一个对隐藏过程自动运行至关重要的细节是将THotCommandsTDescriptionPane 控件的Height 设置为0,因为IDE 似乎重置了它们的Visible在更改 OI 中的组件选择后,属性为 True。幸运的是,无论做什么代码都不会将它们的高度重置为非零值。

显然,要使用您将包含代码的单元添加到包 (.Dpk) 文件中,然后在 IDE 中编译和安装包。

代码:

interface

uses
  [...]ToolsApi, DesignIntf;

type
  TDesignNotification = class(TInterfacedObject, IDesignNotification)
    procedure ItemDeleted(const ADesigner: IDesigner; AItem: TPersistent);
    procedure ItemInserted(const ADesigner: IDesigner; AItem: TPersistent);
    procedure ItemsModified(const ADesigner: IDesigner);
    procedure SelectionChanged(const ADesigner: IDesigner;
      const ASelection: IDesignerSelections);
    procedure DesignerOpened(const ADesigner: IDesigner; AResurrecting: Boolean);
    procedure DesignerClosed(const ADesigner: IDesigner; AGoingDormant: Boolean);
    constructor Create;
    destructor Destroy; override;
  private
    procedure HideItems;
    procedure HideFormItems(Form: TForm);
  end;

var
  DesignNotification : TDesignNotification;

implementation

procedure SetUp;
begin
  DesignNotification := TDesignNotification.Create;
  RegisterDesignNotification(DesignNotification);
end;

constructor TDesignNotification.Create;
begin
  inherited Create;
end;

procedure TDesignNotification.DesignerClosed(const ADesigner: IDesigner;
  AGoingDormant: Boolean);
begin

end;

procedure TDesignNotification.HideFormItems(Form : TForm);
var
  j,
  l : Integer;
  Panel : TPanel;
  C : TComponent;
  HideCount : Integer;

  procedure HideControl(AControl : TControl);
  begin
    AControl.Height := 0;  //  This is necessary because the IDE seems to reset
    //  Visible to True when the Object Inspector is refreshed.
    AControl.Visible := False;
  end;

begin
  HideCount := 0;
  for j := 0 to Form.ComponentCount - 1 do begin
    C := Form.Components[j];
    if C is TPanel then begin
      Panel := TPanel(C);
      for l := 0 to Panel.ControlCount - 1 do begin
        if CompareText(Panel.Controls[l].ClassName, 'TDescriptionPane') = 0 then begin
          HideControl(Panel.Controls[l]);
          Inc(HideCount);
        end
        else
          if CompareText(Panel.Controls[l].ClassName, 'THotCommands') = 0 then begin
            HideControl(Panel.Controls[l]);
            Inc(HideCount);
          end;
        if HideCount >= 2 then  //  we're done
          exit;
      end;
    end;
  end;
end;

procedure TDesignNotification.HideItems;
var
  i : Integer;
  Form : TForm;
begin
  for i := 0 to Screen.FormCount - 1 do begin
    Form := Screen.Forms[i];
    if CompareText(Form.ClassName, 'TPropertyInspector') = 0 then begin
      HideFormItems(Form);
      Break;
    end;
  end;
end;

procedure TDesignNotification.DesignerOpened(const ADesigner: IDesigner;
  AResurrecting: Boolean);
begin

end;

var
  DestroyCount : Integer;

destructor TDesignNotification.Destroy;
begin
  Inc(DestroyCount);
  inherited;
end;

procedure TDesignNotification.ItemDeleted(const ADesigner: IDesigner;
  AItem: TPersistent);
begin

end;

procedure TDesignNotification.ItemInserted(const ADesigner: IDesigner;
  AItem: TPersistent);
begin

end;

procedure TDesignNotification.ItemsModified(const ADesigner: IDesigner);
begin

end;

procedure TDesignNotification.SelectionChanged(const ADesigner: IDesigner;
  const ASelection: IDesignerSelections);
var
  C : TComponent;
begin
  //  This can get called with ADesigner = Nil
  if ADesigner = Nil then
    exit;
  C := ADesigner.Root;
  if C <> Nil then begin
    HideItems;
  end
end;

initialization
  SetUp;
finalization
  if DesignNotification <> Nil then begin
    UnRegisterDesignNotification(DesignNotification);
  end;
end.

【讨论】:

  • 我想将您的代码添加为 GExperts 的 IDE 增强功能。你可以吗?
  • @dummzeuch:是的,那太好了。感谢您整理代码,顺便说一句。
  • 我找到了一种更简洁的隐藏窗格的方法:添加一个隐藏的 TPanel 并将其父级设置为该面板。不幸的是,这使得分离器仍然可见。改变他们的父母也解决了这个问题。但是当我让它们再次可见时,拆分器和窗格的顺序是错误的。我只是讨厌 Borland 实现分离器的方式。
  • 谢谢两位 MartynA 和 dummzeuch!难以置信,我刚问了这个问题,就收到了一个现成的解决方案。伟大的德尔福社区! :)
猜你喜欢
  • 1970-01-01
  • 2016-12-08
  • 2014-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-01
  • 1970-01-01
相关资源
最近更新 更多