gpt4 book ai didi

delphi - 用于禁用 Insert 键的 IDE 插件

转载 作者:行者123 更新时间:2023-12-03 15:46:02 29 4
gpt4 key购买 nike

我一直在使用 Delphi (10.3 Rio) 的 IDE 插件来禁用插入键(有人实际上使用打字模式吗?)。

它可以很好地安装到 IDE 中,但是如果我卸载它,则在按插入键时会发生异常。

有人可以帮我吗?

这是更新的来源:(我已经添加了最终确定部分,但仍然出现错误)

unit MyBinding;

interface

procedure Register;

implementation

uses Windows, Classes, SysUtils, ToolsAPI, Vcl.Menus;

type
TLearnDelphiKeyBinding = class(TNotifierObject, IOTAKeyboardBinding)
private
procedure DoNothing(const Context: IOTAKeyContext; KeyCode: TShortCut; var BindingResult: TKeyBindingResult);

public
function GetBindingType: TBindingType;
function GetDisplayName: string;
function GetName: string;
procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);
end;

var
LearnDelphiKeyBindingIndex : integer = 0;

procedure Register;
begin
LearnDelphiKeyBindingIndex := (BorlandIDEServices as IOTAKeyBoardServices).AddKeyboardBinding(TLearnDelphiKeyBinding.Create);
end;

procedure TLearnDelphiKeyBinding.BindKeyboard(const BindingServices: IOTAKeyBindingServices);
begin
BindingServices.AddKeyBinding([ShortCut(VK_INSERT, [])], DoNothing, nil);
end;

function TLearnDelphiKeyBinding.GetBindingType: TBindingType;
begin
Result := btPartial;
end;

function TLearnDelphiKeyBinding.GetDisplayName: string;
begin
Result := 'Disable Insert';
end;

function TLearnDelphiKeyBinding.GetName: string;
begin
Result := 'LearnDelphi.DisableInsert';
end;

procedure TLearnDelphiKeyBinding.DoNothing(const Context: IOTAKeyContext;
KeyCode: TShortCut; var BindingResult: TKeyBindingResult);
begin
BindingResult := krHandled;
end;

initialization
finalization
if LearnDelphiKeyBindingIndex > 0 then
(BorlandIDEServices as IOTAKeyboardServices).RemoveKeyboardBinding(LearnDelphiKeyBindingIndex);

end.

enter image description here

最佳答案

您需要在最终确定期间调用IOTAKeyboardServices.RemoveKeyboardBinding(),并向其传递IOTAKeyboardServices.AddKeyboardBinding()返回的值(您可以使用该值)当前未保存)。

看看Chapter 4: Key Bindings and Debugging Tools David Hoyle 的博客中提供了使用 OpenTools API 的键盘绑定(bind)向导的示例。

关于delphi - 用于禁用 Insert 键的 IDE 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61763068/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com