计时器取决于封套
timer depends on capslock
我使用visual studio 2010 c++,正在制作一个Windows窗体应用程序。我的问题是我如何做一个定时器,将启动和停止取决于capslock状态,就像它会开始时,capslock是打开和关闭时停止。就像这样
public void keyDownEvent(... )
{
if (capslockOn != 0)
timer1->enabled = true
else
timer1->enabled = false
}
在c++中,你可以使用Windows API函数GetKeyState
来确定CAPS LOCK键的状态:
SHORT WINAPI GetKeyState(
_In_ int nVirtKey
);
测试:if ((GetKeyState(VK_CAPITAL) & 0x0001)!=0)
// Caps Lock is ON
else
// Caps Lock is OFF
,其中VK_CAPITAL
为0x14。低阶位打开或关闭,指示密钥的状态。
相关文章:
- Linux的Cpp上的计时器
- 提升 ASIO 无法识别计时器对象
- 提升 asio 并发计时器取消问题与链
- 使用单体计时器的pthread_cond_timedwait有时会比预期晚超时
- 窗口中的微秒计时器
- 计时器是否从另一个线程启动?
- 如何在 c++ 中创建计时器
- C++回调计时器实现
- 在计时器或主线程外部的命令上销毁/替换线程
- 如何制作每秒从 30 乘 1 倒计时的计时器?
- 保留计时器集合(对象与指针)的最佳方法
- 在网络套接字计时器滴答后增加asio短读错误
- 是否可以仅使用标准 c++/c++11 实现不带"sleep"的计时器?
- 在没有NtSetTimerResolution的Windows上提高计时器分辨率(高分辨率)
- 计时器坏了或者其他什么的
- 功能计时器阻止主功能继续
- IO服务重新启动后,Boost最后期限计时器持续触发
- boost asio计时器是否会在"取消"时阻塞
- Poco 计时器,具有来自同一类的回调
- 计时器取决于封套