zoukankan      html  css  js  c++  java
  • delphi2010:按键 控制键 组合键的判断 响应

    procedure TForm7.FormShortCut(var Msg: TWMKey; var Handled: Boolean); var   aKey: TShortCut;   aShift : TShiftState;   i:integer; begin   aShift:=KeyDataToShiftState(Msg.KeyData);

      i:=msg.CharCode;

      if (ssAlt in ashift)and (i=115)  then   halt;

    end;

     

    https://yq.aliyun.com/articles/527004

    delphi2010:按键 控制键 组合键的判断 响应

     
    技术小甜 2017-11-16 19:22:00 浏览105 评论0

    摘要: 在delphi根据TshiftState值来判断用户按下Ctrl,shift,alt等键的方法 procedure TForm1.FormMouseDown(Sender:TObject; Button: TMouseButton;Shift:TShiftState; X, Y: Integer); begin if ssCtrl in shift thenShowMessage('ssCtrl'); shift 是一个集合变量。

    在delphi根据TshiftState值来判断用户按下Ctrl,shift,alt等键的方法

    procedure TForm1.FormMouseDown(Sender:TObject; Button: TMouseButton;
    Shift:TShiftState; X, Y: Integer);
    begin
    if ssCtrl in shift then
    ShowMessage('ssCtrl');

    shift 是一个集合变量。type TShiftState = setof (ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle,ssDouble);

    Value Meaning

    ssShift The Shift key is held down.
    ssAlt The Alt key is held down.
    ssCtrl The Ctrl key is held down.
    ssLeft The left mouse button is held down.
    ssRight The right mouse button is held down.
    ssMiddle The middle mouse button is held down.
    ssDouble The mouse was double-clicked.

     

    delphi中如何响应键盘的组合键(如:ctrl k),

    var Hot: boolean;
    procecure form1.formkeydown(.....);
    begin
    if (key = VK_K) and (ssShift in shift) then
    if hot then
    begin
    //处理ctrl kk
    hot := false;
    end
    else hot := true
    else
    hot := false;
    end;


    可以设置快捷键,也可以在程序中设置,如上

    set Form1.KeyPreview totrue.

    procedure TForm1.FormKeyDown(Sender:TObject; var Key: Word;
    Shift: TShiftState);
    begin
    if (ssCtrl in Shift) and (Char(Key) in ['K', 'k']) then
    ShowMessage('Ctrl K');
    end;
    一般的onkeydown就可以了
    最好是设置一个全局的热键,系统中的任何地方都可以响应到:
    下面这个帖子里很多:看看,帮助很大:

    delphi lazarus opengl 网页操作自动化, 图像分析破解,游戏开发
  • 相关阅读:
    AB测试原理及样本量计算的Python实现
    数据分析-A/B test
    数据分析-分类分析
    数据分析-漏斗模型(AARRR模型)
    置信区间的I型错误和II型错误
    tableau 计算字段
    tableau数据分层、数据组、数据集
    tableau 地图
    tableau 进阶
    tableau 基础
  • 原文地址:https://www.cnblogs.com/delphi-xe5/p/9503512.html
Copyright © 2011-2022 走看看