2

オブジェクト インスペクタの下部にある 2 つのペインはまったく役に立たず、下のスクリーンショットに示されているように、不必要に画面領域を消費しています。IDE を再起動した後でも、その 2 つのペインを無効にする方法は? 組み込みのオプションまたはサードパーティのプラグインは、私には問題ありません。ありがとう。 ここに画像の説明を入力

4

1 に答える 1

5

以下の XE4 コードは、削除するアイテムを非表示にする方法を示しています。これらは、クラスTHotCommandsおよびのインスタンスですTDescriptionPane

更新この回答の元のバージョンでは、アドイン フォームと、オブジェクト インスペクタを更新して 2 つの不要なアイテムを非表示にするボタンを含むパッケージが必要でした。以下のコードでは、フォームを完全に削除し、アイテムの非表示が完全に自動化されているはずです。これを実現するために、以前の IDENotifier をDesignNotificationオブジェクトに置き換え、その SelectionChangedイベントを使用してTHotCommandsおよびTDescriptionPaneコントロールを非表示にするコードを呼び出しました。 DesignIntf​​.Pas でインターフェイスをTDesignNotification実装しますIDesignNotification

非表示プロセスを自動的に機能させるために重要であることが判明したその他の詳細Heightは、THotCommandsおよびコントロールの を 0 に設定することです。これは、OI でコンポーネントの選択が変更された後、 IDE がそれらのプロパティをTDescriptionPaneにリセットするように見えるためです。幸いなことに、どのようなコードを実行しても、Heights がゼロ以外の値にリセットされることはありません。VisibleTrue

明らかに、使用するには、コードを含むユニットをパッケージ (.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.
于 2017-01-06T17:13:06.393 に答える