如何吸收密钥preSS? [英] How to Absorb a Keypress?

查看:163
本文介绍了如何吸收密钥preSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表,我有一个编辑控件。我已成立了一个的KeyDown 事件当用户按下<大骨节病>输入来检测,但我也想检测<大骨节病> Shift +空格因此用户可以清除框中的内容。

该功能的工作原理 - 我可以检测重点preSS。问题是,在空间不会被吸收,所以该空间字形仍输入了控制

我如何能够吸收的关键preSS当我把<大骨节病> Shift +空格

 私人小组FindBox_KeyDown(主要code为整数,转变为整数)
    选择重点案例code
        案例vbKeyEnter:SearchForIt
        案例vbKeySpace:
            如果移位= 1,则
                FindBox.Text =
                这里吸收,而不是发送空间控制键preSS
                退出小组
            结束如果
    最终选择
结束小组
 

解决方案

您只需要设置的主要code = 0,这将吞键并没有发生任何事的价值。

您也想使用位掩码来寻找转变的presence是pressed

 昏暗intShiftDown作为整数
intShiftDown =(移和acShiftMask)&GT; 0

    案例vbKeySpace:
        如果intShiftDown然后
            FindBox.Text =
            这里吸收,而不是发送空间控制键preSS
            主要code = 0
            退出小组
 

On my form I have an edit control. I have set up a KeyDown event to detect when the user pushes enter, but I also want to detect shift+space so the user can clear the contents of the box.

The functionality works - I can detect the keypress. Problem is that the space does not get absorbed and so the space glyph is still typed in the control.

How can I absorb the keypress when I push shift+space?

Private Sub FindBox_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyEnter: SearchForIt
        Case vbKeySpace:
            If Shift = 1 Then
                FindBox.Text = ""
                'here absorb keypress instead of sending space to control
                Exit Sub
            End If
    End Select
End Sub

解决方案

You just need to set the value of KeyCode = 0. That will "swallow" the key and not have anything happen.

You also want to use the bit mask to look for the presence of the shift being pressed

Dim intShiftDown As Integer
intShiftDown = (Shift And acShiftMask) > 0 

    Case vbKeySpace:
        If intShiftDown Then
            FindBox.Text = ""
            'here absorb keypress instead of sending space to control
            KeyCode = 0
            Exit Sub

这篇关于如何吸收密钥preSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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