オブジェクト インスペクタの下部にある 2 つのペインはまったく役に立たず、下のスクリーンショットに示されているように、不必要に画面領域を消費しています。IDE を再起動した後でも、その 2 つのペインを無効にする方法は? 組み込みのオプションまたはサードパーティのプラグインは、私には問題ありません。ありがとう。
1 に答える
以下の XE4 コードは、削除するアイテムを非表示にする方法を示しています。これらは、クラスTHotCommands
およびのインスタンスですTDescriptionPane
。
更新この回答の元のバージョンでは、アドイン フォームと、オブジェクト インスペクタを更新して 2 つの不要なアイテムを非表示にするボタンを含むパッケージが必要でした。以下のコードでは、フォームを完全に削除し、アイテムの非表示が完全に自動化されているはずです。これを実現するために、以前の IDENotifier をDesignNotification
オブジェクトに置き換え、その
SelectionChanged
イベントを使用してTHotCommands
およびTDescriptionPane
コントロールを非表示にするコードを呼び出しました。 DesignIntf.Pas でインターフェイスをTDesignNotification
実装しますIDesignNotification
非表示プロセスを自動的に機能させるために重要であることが判明したその他の詳細Height
は、THotCommands
およびコントロールの を 0 に設定することです。これは、OI でコンポーネントの選択が変更された後、 IDE がそれらのプロパティをTDescriptionPane
にリセットするように見えるためです。幸いなことに、どのようなコードを実行しても、Heights がゼロ以外の値にリセットされることはありません。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.