CnPack Forum


 
Subject: 如何利用脚本专家隐藏 RAD Studio 10 Seattle 自带的编辑器工具栏
kendling (小冬)
高级版主
Rank: 8Rank: 8
MyvNet


Medal No.1  
UID 703
Digest Posts 5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
Post at 2015-9-18 14:38  Profile | Site | Blog | P.M.  | QQ | Yahoo!
如何利用脚本专家隐藏 RAD Studio 10 Seattle 自带的编辑器工具栏

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

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.





小冬
http://MyvNet.com
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2015-9-18 16:19  Profile | Blog | P.M. 


小冬好厉害。这个执行后,当前IDE编辑器的那个工具栏就不见了,不过重启IDE后又出现了。
Top
hq200306
灌水科科长
Rank: 3Rank: 3



UID 67758
Digest Posts 0
Credits 106
Posts 36
点点分 106
Reading Access 10
Registered 2012-12-1
Status Offline
Post at 2015-10-26 07:27  Profile | Blog | P.M. 
同步了下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;
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2015-10-26 09:44  Profile | Blog | P.M. 
楼主是Pascal脚本,可以在IDE内动态执行。
楼上的是CnPack内的代码,需要重新编译。
Top
xjw100
灌水科科长
Rank: 3Rank: 3


UID 1476
Digest Posts 0
Credits 134
Posts 74
点点分 134
Reading Access 10
Registered 2005-12-13
Location 桂林
Status Offline
Post at 2015-11-21 11:42  Profile | Blog | P.M. 
这个方法很彻底,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.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2015-11-24 10:38  Profile | Blog | P.M. 
最新的每日构建版中,我们在自带的编辑器工具栏上加了个右键菜单。
Top
 




All times are GMT++8, the time now is 2024-12-4 01:39

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007846 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP