是否自动允许Ctrl + A选择TMemo中的全部? [英] Automatically allowing Ctrl+A to select all in a TMemo?

查看:101
本文介绍了是否自动允许Ctrl + A选择TMemo中的全部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi 7的TMemo控件中,尝试执行组合键Ctrl + A以选择全部不会执行任何操作(不会选择全部).所以我做了这个过程:

In Delphi 7's TMemo control, an attempt to do the key combo Ctrl + A to select all does not do anything (doesn't select all). So I've made this procedure:

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  C: String;
begin
  if ssCtrl in Shift then begin
    C:= LowerCase(Char(Key));
    if C = 'a' then begin
      Memo1.SelectAll;
    end;
  end;
end;

是否有技巧,所以我不必执行此过程?如果不是,那么此过程看起来还可以吗?

Is there a trick so that I don't have to do this procedure? And if not, then does this procedure look OK?

推荐答案

这更优雅:

procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = ^A then
  begin
    (Sender as TMemo).SelectAll;
    Key := #0;
  end;
end;

这篇关于是否自动允许Ctrl + A选择TMemo中的全部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆