封装 TMemo、TDBMemo 控件(支持 Ctrl+A 全选功能)在KeyDown事件中
if (Key = 65) and (Shift = [ssCtrl]) then 
  (Sender as TCustomMemo).SelectAll;这个是最基本的,小弟搞了快1年delphi了,
第一次要封装控件。大家给点提示或者代码,谢谢!

解决方案 »

  1.   

    unit MemoExU;interfaceuses
      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.这样试试!
      

  2.   

    会吗?我这里是把他放到dclusr50.dpk包里的,我用的是D5
      

  3.   

    我也加了Bpl了就是上面还是没啊
      

  4.   

    unit LebutMemo;interfaceuses
      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.帮我看看  有什么问题吗?
      

  5.   

    能安装了吗?你要设置一下路径~~~
    Tools->Library->Library path
    加入你的UNIT所在的路径!