我在做BITBTN按钮的CAPTION上写 确定(&Y),只要按AIL+Y就可以了,为什么按Y键也可以呀,我只要按AIL+Y,怎样可以屏蔽Y键呀?

解决方案 »

  1.   

    一般不会有这种情况呀,是不是你的BITBTN已经获得焦点的时候按Y键好使呢?
    如果BITBTN没有获得焦点按Y键也一样好使嘛?还是ALT+Y才好使呢
      

  2.   

    无论有没有获得焦点,按Y键都会管用。
    解决:
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    begin
    if (Key=VK_LALT) and (Key=VK_Y) then
      begin
      //..........
      end;
    end;
    具体的键值看帮助。
      

  3.   

    form1的keypreview属性设置为true;
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=VK_Y then
        key:=0;
      if (key=VK_Y) and ([ssALT]=shift) then
      begin
        .
        .
        .
      end;
    end;
      

  4.   

    ActionList控件,他就在Standard页
    双击空间,在其中加入一条Action1,将Action1事件属性OnExecute指向你的Button1Click事件,设置shortcut属性为你的快捷键即可。