首页 > 解决方案 > 为什么 THotKey 没有 Align 属性,我该如何添加它?

问题描述

在 Windows 10 的 Delphi 10.4.2 32 位 VCL 应用程序中,我尝试使用THotKey控件输入热键。由于我经常使用Align属性来创建整洁的 UI,我想知道为什么THotKey没有Align属性。甚至TRzHotKeyEdit,TJvHotKeyTJvDotNetHotKey没有Align属性。

是否可以模拟THotkey.Align属性?或者是否有另一个带有Align属性的 HotKey 控件?

标签: delphihotkeysdelphi-10.4-sydney

解决方案


创建一个单元以将其用作派生自的新组件THotKey

unit ExtHotKey;

// Published the Align property

interface

uses
  System.Classes,
  Vcl.ComCtrls;

type
  TExtHotKey = class(THotKey)
  published
    property Align;
  end;

procedure Register;

implementation

procedure Register;
begin
  System.Classes.RegisterComponents('PAComponents', [TExtHotKey]);
end;

end.

然后将其插入新的或现有的包中并安装该包。

之后,该Align属性在 Object Inspector 中可用,并且运行良好:

在此处输入图像描述


推荐阅读