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 网页操作自动化, 图像分析破解,游戏开发
  • 相关阅读:
    Jenkins自动化测试环境搭建
    在windows上运行python程序
    DOS命令笔记
    批处理基础语法
    一键清理c盘垃圾文件--bat文件
    Centos7中打包docker离线包
    python之正则表达式使用
    LoadRunner11使用代理录制脚本
    快速查看日志脚本
    实现两种登录方式一键切换的脚本及相关知识点
  • 原文地址:https://www.cnblogs.com/delphi-xe5/p/9503512.html
Copyright © 2011-2022 走看看