在状态栏上显示开/关状态 [英] show caps on/off status on status strip

查看:76
本文介绍了在状态栏上显示开/关状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,如果我按下Caps按钮和num按钮,可以帮助我显示Caps and num Lock是打开还是关闭.

Hi, can any one help me to show whether caps and num lock is on or off if i press caps button and num button. thnx in advance..

推荐答案

从第二个链接听起来很简单. 从您的计算机中读取和更新CAPS或NUM锁定状态应用程序 [ ^ ]
http://social.msdn.microsoft.com /Forums/zh-CN/winforms/thread/cf06fc03-331e-4e33-a696-946c9aeb0ab3/ [
It sounds very simple from 2nd link..check those..
Read and Update CAPS or NUM Lock Status from your Application[^]
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/cf06fc03-331e-4e33-a696-946c9aeb0ab3/[^]


public KeyStatusStatusBar(bool CapsLock, bool NumLock)
{
 // This call is required by the Windows.Forms Form Designer.
 InitializeComponent();
 ...
 Application.Idle += new System.EventHandler(OnIdle);
}
...
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);

public void OnIdle(object sender, EventArgs e)
{
 // Update the panels when the program is idle.
 bool CapsLock = (((ushort) GetKeyState(0x14 /*VK_CAPITAL*/)) & 0xffff) != 0;
 bool NumLock  = (((ushort) GetKeyState(0x90 /*VK_NUMLOCK*/)) & 0xffff) != 0;
 if (CapsLockPanel != null)
 {
  CapsLockPanel.Text = CapsLock ? "CAP" : "";
 }
 if (NumLockPanel != null)
 {
  NumLockPanel.Text  = NumLock  ? "NUM" : "";
 }
}


这篇关于在状态栏上显示开/关状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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