gpt4 book ai didi

Delphi XE4 IDE,如何始终隐藏对象检查器的底部 Pane

转载 作者:行者123 更新时间:2023-12-03 18:20:52 29 4
gpt4 key购买 nike

位于对象检查器底部的两个 Pane 根本没有用处,而且它不必要地消耗了屏幕空间,如下面的屏幕截图所示。即使重新启动 IDE 后如何禁用这两个 Pane ?内置选项或第三方插件对我来说没问题。谢谢。 enter image description here

最佳答案

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

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

事实证明,对于让隐藏过程自动工作至关重要的另一个细节是设置 THotCommandsTDescriptionPaneHeight > 控件设置为 0,因为在 OI 中的组件选择更改后,IDE 似乎将其 Visible 属性重置为 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.

关于Delphi XE4 IDE,如何始终隐藏对象检查器的底部 Pane ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41501400/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com