封装 TMemo、TDBMemo 控件(支持 Ctrl+A 全选功能)在KeyDown事件中
if (Key = 65) and (Shift = [ssCtrl]) then
(Sender as TCustomMemo).SelectAll;这个是最基本的,小弟搞了快1年delphi了,
第一次要封装控件。大家给点提示或者代码,谢谢!
if (Key = 65) and (Shift = [ssCtrl]) then
(Sender as TCustomMemo).SelectAll;这个是最基本的,小弟搞了快1年delphi了,
第一次要封装控件。大家给点提示或者代码,谢谢!
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TMemoEx = class(TMemo)
private protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TMemoEx]);
end;{ TMemoEx }
{ TMemoEx }procedure TMemoEx.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited;
if (Key = 65) and (Shift = [ssCtrl]) then SelectAll;
end;end.这样试试!
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TLebutMemo = class(TMemo)
private protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
{ Public declarations }
published
{ Published declarations }
end;procedure register;implementation{ TLebutMemo }procedure TLebutMemo.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited; if (Key = 65) and (Shift = [ssCtrl]) then
SelectAll;
end;procedure register;
begin
RegisterComponents('Lebut', [TLebutMemo]);
end;initialization
RegisterClass(TLebutMemo);end.帮我看看 有什么问题吗?
Tools->Library->Library path
加入你的UNIT所在的路径!