我要让按下ctrl+X时触发一个事件,如showmessage(''),应该怎么写?

解决方案 »

  1.   

    if ssCtrl in Shift then
        begin
          if (Key in RowMovementKeys) then ClearSelection;
          case Key of
            VK_UP, VK_PRIOR: FDataLink.MoveBy(-FDatalink.ActiveRecord);
            VK_DOWN, VK_NEXT: FDataLink.MoveBy(FDatalink.BufferCount - FDatalink.ActiveRecord - 1);
            VK_LEFT: MoveCol(FIndicatorOffset, 1);
            VK_RIGHT: MoveCol(ColCount - 1, -1);
            VK_HOME: First;
            VK_END: Last;
            VK_DELETE:
              if (not ReadOnly) and not IsEmpty
                and CanModify and DeletePrompt then
              if FBooks.Count > 0 then
                FBooks.Delete
              else
                Delete;
          end
        end
        else
          case Key of
            VK_UP: PriorRow(True);
            VK_DOWN: NextRow(True);
            VK_LEFT:
              if dgRowSelect in Options then
                PriorRow(False) else
                MoveCol(Col - 1, -1);
            VK_RIGHT:
              if dgRowSelect in Options then
                NextRow(False) else
                MoveCol(Col + 1, 1);
            VK_HOME:
              if (ColCount = FIndicatorOffset+1)
                or (dgRowSelect in Options) then
              begin
                ClearSelection;
                First;
              end
              else
                MoveCol(FIndicatorOffset, 1);
            VK_END:
              if (ColCount = FIndicatorOffset+1)
                or (dgRowSelect in Options) then
              begin
                ClearSelection;
                Last;
              end
              else
                MoveCol(ColCount - 1, -1);
            VK_NEXT:
              begin
                ClearSelection;
                FDataLink.MoveBy(VisibleRowCount);
              end;
            VK_PRIOR:
              begin
                ClearSelection;
                FDataLink.MoveBy(-VisibleRowCount);
              end;
            VK_INSERT:
              if CanModify and (not ReadOnly) and (dgEditing in Options) then
              begin
                ClearSelection;
                Insert;
              end;
            VK_TAB: if not (ssAlt in Shift) then Tab(not (ssShift in Shift));
            VK_ESCAPE:
              begin
                if SysLocale.PriLangID = LANG_KOREAN then
                  FIsESCKey := True;
                FDatalink.Reset;
                ClearSelection;
                if not (dgAlwaysShowEditor in Options) then HideEditor;
              end;
            VK_F2: EditorMode := True;
          end;
    自己改改
      

  2.   

    if (shift=[ssctrl]) and (key=key_x) then
      ShowMessage('sdfk');
      

  3.   

    这个事件要写在onkeydown事件里吗?
      

  4.   

    是,还要将Form的Keypreview设置成True