Board logo

Subject: 如何利用脚本专家隐藏 RAD Studio 10 Seattle 自带的编辑器工具栏 [Print This Page]

Author: kendling    Time: 2015-9-18 14:38     Subject: 如何利用脚本专家隐藏 RAD Studio 10 Seattle 自带的编辑器工具栏

直接上代码吧,有兴趣朋友可以详细看看代码。

[Copy to clipboard]
CODE:
program HideEditorToolBar;

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

var
  I: Integer;
  Control: TControl;
  Parent: TWinControl;
begin
  Control := CnOtaGetCurrentEditControl;
  if Control = nil then
  begin
    ErrorDlg('NO EditControl Found.');
    Exit;
  end;

  Parent := Control.Parent;
  if Parent = nil then
  begin
    ErrorDlg('NO EditControl Parent Found.');
    Exit;
  end;

  Parent := Parent.Parent;
  if Parent = nil then
  begin
    ErrorDlg('NO EditControl Parent^2 Found.');
    Exit;
  end;

  for I := 0 to Parent.ControlCount - 1 do
  begin
    Writeln(Parent.Controls[I].ClassName);

    if Parent.Controls[I].ClassNameIs('TEditorNavigationToolbar') then
    begin
      (Parent.Controls[I] as TToolbar).AutoSize := False;
      Parent.Controls[I].Height := 0;
      Parent.Controls[I].Visible := False;
    end;
  end;
end.


Author: Passion    Time: 2015-9-18 16:19



小冬好厉害。这个执行后,当前IDE编辑器的那个工具栏就不见了,不过重启IDE后又出现了。
Author: hq200306    Time: 2015-10-26 07:27     Subject: 同步了下cnpack代码,改成以下

procedure TCnSrcEditorMisc.OnSourceEditorNotify(
  SourceEditor: IOTASourceEditor; NotifyType: TCnWizSourceEditorNotifyType;
  EditView: IOTAEditView);
var
  I: Integer;
  EditBuff: IOTAEditBuffer;
{$IFDEF DELPHI10_SEATTLE_UP}
  Control: TControl;
  Parent: TWinControl;
  TmpCtrl: TControl;
{$ENDIF}
begin
  if FActive then
  begin
    // 只读保护
    if FAutoReadOnly and (NotifyType = setOpened) and (SourceEditor <> nil) and
      Supports(SourceEditor, IOTAEditBuffer, EditBuff) then
    begin
      for I := 0 to FActualDirs.Count - 1 do
      begin
        if AnsiPos(FActualDirs[I], UpperCase(SourceEditor.FileName)) = 1 then
        begin
          EditBuff.IsReadOnly := True;
          Break;
        end;
      end;
    end;

{$IFDEF DELPHI10_SEATTLE_UP}
    if FHideOrigToolbar and (NotifyType = setEditViewActivated) then
    begin
      Control := CnOtaGetCurrentEditControl;
      if Control = nil then
        Exit;

      Parent := Control.Parent;
      if Parent = nil then
        Exit;

      Parent := Parent.Parent;
      if Parent = nil then
        Exit;

      for I := 0 to Parent.ControlCount - 1 do
      begin
        TmpCtrl := Parent.Controls[I];
        if TmpCtrl.ClassNameIs('TEditorNavigationToolbar') then
        begin
          if TmpCtrl.Visible then
          begin
            (TmpCtrl as TToolbar).AutoSize := False;
            TmpCtrl.Height := 0;
            TmpCtrl.Visible := False;
          end;
          Exit;
        end;
      end;
    end;
{$ENDIF}
  end;
end;
Author: Passion    Time: 2015-10-26 09:44

楼主是Pascal脚本,可以在IDE内动态执行。
楼上的是CnPack内的代码,需要重新编译。
Author: xjw100    Time: 2015-11-21 11:42

这个方法很彻底,unis大神的作品.NavBarKiller http://rghost.net/6CwHQlRVB
unit Patcher;

interface

uses Windows, System.SysUtils;

implementation

var
  PackageModule: HModule;
  fp: FARPROC;
  dw: DWORD;

initialization
  //MessageBox(0, 'initialization', 'initialization', MB_OK);
  PackageModule := LoadPackage('coreide230.bpl');
  if PackageModule <> 0 then
  begin
    fp := GetProcAddress(PackageModule, '@Editornavbar@IDERegister$qqrv');
    if fp <> nil then
    begin
      VirtualProtect(fp, 1, PAGE_EXECUTE_READWRITE, @dw);
      PByte(fp)^ := $C3;
      VirtualProtect(fp, 1, dw, @dw);
    end;
  end;

finalization
  //MessageBox(0, 'finalization', 'finalization', MB_OK);
  if PackageModule <> 0 then
    UnloadPackage(PackageModule);


end.
Author: Passion    Time: 2015-11-24 10:38

最新的每日构建版中,我们在自带的编辑器工具栏上加了个右键菜单。




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0