在CAPS LOCK按钮上编程 [英] programming on CAPS LOCK button

查看:60
本文介绍了在CAPS LOCK按钮上编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在为我的项目编程一个虚拟键盘,除CAPS锁定按钮外,所有按钮上都有wirtten代码.我无法为CAPS按钮编写代码.
例如.如果我单击CAPS按钮,然后单击任何字母,则它应以大写字母出现;如果再次单击CAPS按钮,则字母应以小写字母进入.

我快要达到目标日期,请给我帮忙:(

预先感谢:)

Hi Everyone,

I am programming a Virtual keyboard for my project, I have wirtten code on all buttons except CAPS lock button. I am not able to write a code for CAPS button.
For eg. If i click on CAPS buttons and then any alphabet is clicked then it should come in CAPITAL letter, if again CAPS button is clicked then alphabets should come in SMALL letters.

Please help me as I am near to my Target date :(

Thanks in advance :)

推荐答案

您应该已经分享了一些如何编程VK的代码.

You should have shared a little code how you have programmed VK.

Private Declare Sub keybd_event Lib "user32" ( _
      ByVal bVk As Byte, _
      ByVal bScan As Byte, _
      ByVal dwFlags As Integer, _
      ByVal dwExtraInfo As Integer _
  )
Private Const VK_CAPITAL As Integer = &H14
Private Const KEYEVENTF_EXTENDEDKEY As Integer = &H1
Private Const KEYEVENTF_KEYUP As Integer = &H2

Private Sub CAPS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAPS.Click
  keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0)
  keybd_event(VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End Sub



如果您使用的是sendkeys ,则可以使用此代码切换大写字母状态.
否则,您需要一个标记来记住CAPS状态,并且需要相应地附加.


使用您描述的逻辑,必须在类级别定义一个标志,以保持CAPSLOCK状态,例如isCAPS.

单击CAPS时,必须切换该标志.



You can use this code to toggle caps status if you are using sendkeys.
Otherwise, you need a flag to remember the CAPS status, and you need to append accordingly.


With the logic you described, you have to have a flag defined at class level to maintain CAPSLOCK status say isCAPS.

On CAPS click, you have to toggle that flag.

Private Sub CAPS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAPS.Click
    isCAPS = Not isCAPS
  End Sub



最后,在追加字符输入时,您必须检查该标志.



And atlast, while appending a character input, you have to check that flag.

If isCAPS Then
  'capital letter
Else
  'small letter
End If



希望这对您有所帮助.



Hope this helps now.


这篇关于在CAPS LOCK按钮上编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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