簡體   English   中英

Delphi XE4 IDE,如何始終隱藏對象檢查器的底部窗格

[英]Delphi XE4 IDE, how to always hide the bottom panes of the Object Inspector

位於Obeject檢查器底部的兩個窗格完全沒有用,並且不必要地占用了屏幕資源,如下面的屏幕快照所示。 即使重新啟動IDE,如何禁用兩個窗格? 內置選項或第三方插件對我來說還可以。 謝謝。 在此處輸入圖片說明

下面的XE4代碼顯示了如何隱藏要刪除的項目:它們是THotCommandsTDescriptionPane類的實例。

更新此答案的原始版本需要一個包含加載項表格和刷新對象檢查器以隱藏兩個不需要的項目的按鈕的程序包。 在下面的代碼中,我完全刪除了表單,並且項目的隱藏現在應該是全自動的。 為此,我用DesignNotification對象替換了以前的IDENotifier,並使用其SelectionChanged事件來調用隱藏THotCommandsTDescriptionPane控件的代碼。 TDesignNotificationIDesignNotification中實現IDesignNotification接口

另一個對於使隱藏過程自動運行至關重要的細節是將THotCommandsTDescriptionPane控件的Height設置為0,因為在OI中選擇了組件后,IDE似乎將其Visible屬性重置為True改變。 幸運的是,無論執行什么代碼,都不會將其Heights重置為非零值。

顯然,要使用它,請將包含代碼的單元添加到包(.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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM