123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
- {
- public partial class SNCodeEnterTextBox : TextBox
- {
- [DllImport("user32.dll", EntryPoint = "GetKeyboardState")]
- public static extern int GetKeyboardState(byte[] pbKeyState);
- public static bool CapsLockStatus
- {
- get
- {
- byte[] bs = new byte[256];
- GetKeyboardState(bs);
- return (bs[0x14] == 1);
- }
- }
- private string ID1;
- private string Power1;
- private string str;
- private string str1;
- private string str2;
- /// <summary>
- /// 设置锁定字段
- /// </summary>
- string AllPower1;
- public string AllPower
- {
- get { return AllPower1; }
- set { AllPower1 = value; }
- }
- public string ID
- {
- get { return ID1; }
- set { ID1 = value; }
- }
- public string Str
- {
- get { return str; }
- set { str = value; }
- }
- public string Str1
- {
- get { return str1; }
- set { str1 = value; }
- }
- public string Str2
- {
- get { return str2; }
- set { str2 = value; }
- }
- public string Power
- {
- get { return Power1; }
- set { Power1 = value; }
- }
- public SNCodeEnterTextBox()
- {
- InitializeComponent();
- }
- private void SNCodeEnterTextBox_Leave(object sender, EventArgs e)
- {
- this.BackColor = Color.White;
- }
- private void SNCodeEnterTextBox_Enter(object sender, EventArgs e)
- {
- this.BackColor = Color.GreenYellow;
- }
- private void SNCodeEnterTextBox_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.A)
- this.SelectAll();
- //不允许开启大写扫描
- if (e.KeyCode == Keys.Enter)
- {
- if (CapsLockStatus)
- {
- Text = "";
- BaseUtil.ShowError("请关闭大写锁定键[Caps Lock]");
- }
- }
- }
- }
- }
|