本文介绍了自定义输入控件 - 从头开始​​的文本框(Keyb布局问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 晚上好! 我从头开发了一个自定义文本框(仅继承Windows.Forms.Control)。 一切正常! (选择,光标,命令,文本滚动等) 我的问题是正确映射键盘。我写了一个类(键x值)来识别键盘; 嗯,问题是:键盘地图是完全手动的,就像这个ABNT布局的例子 ''' < 摘要 > ''' 指定键盘布局ABNT2 '' ' < / summary > 公开 类 KeyboardLayoutAbnt2 继承 KeyboardLayout #RegionMethods 私人 Sub SetKeys() ' //数字 ' // KeyEntry构造函数: ' // Sub New(keycode As Integer,keyvalue As Char,shiftedchar As Char) 调用添加(新 KeyEntry(Keys.D1, 1, !, ¹)) 调用添加(新 KeyEntry(Keys.D2, 2, @, ²)) 调用添加(新 KeyEntry(Keys.D3, 3, #, ³)) 调用添加(新 KeyEntry(Keys.D4, 4, $, £)) 致电添加(新 KeyEntry(Keys.D5, 5, %, ¢)) 调用添加(新 KeyEntry(Keys.D6, 6, ¨, ¬)) 调用添加(新 KeyEntry(Keys.D7, 7, &)) 调用添加(新 KeyEntry(Keys.D8, 8, * )) 致电添加(新 KeyEntry(Keys.D9, 9, ()) 调用添加(新 KeyEntry(Keys.D0, 0, ))) 调用添加(新 KeyEntry(Keys.NumPad1, 1, !, ¹)) 调用添加(新 KeyEntry(Keys.NumPad2, 2, @, ²)) 调用添加(新 KeyEntry(Keys.NumPad3, 3, #, ³)) 调用添加(新 KeyEntry(Keys.NumPad4, 4, $, £)) 致电添加(新 KeyEntry(Keys.NumPad5, 5, %, ¢)) 调用添加(新 KeyEntry(Keys.NumPad6, 6, ¨, ¬)) 调用添加(新 KeyEntry(Keys.NumPad7, 7, &)) 调用添加(新 KeyEntry(Keys.NumPad8, 8, *)) 调用添加(新 KeyEntry(Keys.NumPad9, 9, () ) 调用添加(新 KeyEntry(Keys.NumPad0, 0, ))) ' //操作 调用添加(新 KeyEntry(Keys.Divide, /, )) 调用添加(新 KeyEntry(Keys.Multiply, *, )) 调用添加(新 KeyEntry(Keys.Subtract, - , )) 调用添加(新 KeyEntry(键.Add, +, )) 调用添加(新 KeyEntry(Keys。 Decimal , 。 , )) 我想用密钥ha创建控件从窗口开始,因为将来我会尝试实施IME。 请,任何人都可以帮助我应对这一挑战。我失去了所有的头发解决方案 , £)) 致电添加(新 KeyEntry(Keys.D5, 5, %, ¢)) 调用添加(新 KeyEntry(Keys.D6, 6, ¨, ¬)) 调用添加(新 KeyEntry(Keys.D7, 7, &)) 致电添加(新 KeyEntry(Keys.D8, 8, *)) 调用添加(新 KeyEntry(Keys.D9, 9, ()) 调用添加(新 KeyEntry(Keys.D0, 0, ))) 调用添加(新 KeyEntry(Keys.NumPad1 , 1, !, ¹)) 致电添加(新 KeyEntry(Keys.NumPad2, 2 , @, ²)) 调用添加(新 KeyEntry(Keys.NumPad3, 3, #, ³)) 调用添加(新 KeyEntry(Keys.NumPad4 , 4, , £)) 调用添加(新 KeyEntry(Keys.NumPad5, 5, %, ¢)) 致电添加( 新 KeyEntry(Keys.NumPad6, 6, ¨, ¬)) 调用添加(新增功能 KeyEntry(Keys.NumPad7, 7, &)) 调用添加(新 KeyEntry(键.NumPad8, 8, *)) 致电添加(新增 KeyEntry(Keys.NumPad9, 9, ()) 调用添加(新 KeyEntry(Keys.NumPad0, 0, ))) ' // ope口粮 调用添加(新 KeyEntry(Keys.Divide, /, )) 调用添加(新 KeyEntry(键.Multiply, *, )) 调用添加(新 KeyEntry(Keys.Subtract, - , )) 调用添加(新 KeyEntry(Keys.Add, +, )) 调用添加(新 KeyEntry(键。十进制, 。, )) 我想使用windows中的密钥处理来创建控件,因为将来我会尝试实现IME。 拜托,任何人都可以帮助我应对这一挑战。我正在失去所有的头发 请使用事件 KeyPress ,因为它会为您提供字母的字符。它将保留系统键盘布局,因此您无需单独处理每个键。使用 KeyDown 来处理较低级别的键,例如F1,F2等。 -SA Good evening!I developed a custom textbox from scratch (inheriting Windows.Forms.Control only).All working fine! (selections, cursors, commands, text scrolling, etc)my problem is to map the keyboard correctly. I wrote a class (key x value) for identify the keyboard;Well, the problem is: the map of keyboard is totally manually, like this example of ABNT layout''' <summary>''' Specifies a keyboard layout ABNT2''' </summary>Public Class KeyboardLayoutAbnt2 Inherits KeyboardLayout#Region "Methods" Private Sub SetKeys() '//numbers '// KeyEntry Constructor: '// Sub New(keycode As Integer, keyvalue As Char, shiftedchar As Char) Call Add(New KeyEntry(Keys.D1, "1", "!", "¹")) Call Add(New KeyEntry(Keys.D2, "2", "@", "²")) Call Add(New KeyEntry(Keys.D3, "3", "#", "³")) Call Add(New KeyEntry(Keys.D4, "4", "$", "£")) Call Add(New KeyEntry(Keys.D5, "5", "%", "¢")) Call Add(New KeyEntry(Keys.D6, "6", "¨", "¬")) Call Add(New KeyEntry(Keys.D7, "7", "&")) Call Add(New KeyEntry(Keys.D8, "8", "*")) Call Add(New KeyEntry(Keys.D9, "9", "(")) Call Add(New KeyEntry(Keys.D0, "0", ")")) Call Add(New KeyEntry(Keys.NumPad1, "1", "!", "¹")) Call Add(New KeyEntry(Keys.NumPad2, "2", "@", "²")) Call Add(New KeyEntry(Keys.NumPad3, "3", "#", "³")) Call Add(New KeyEntry(Keys.NumPad4, "4", "$", "£")) Call Add(New KeyEntry(Keys.NumPad5, "5", "%", "¢")) Call Add(New KeyEntry(Keys.NumPad6, "6", "¨", "¬")) Call Add(New KeyEntry(Keys.NumPad7, "7", "&")) Call Add(New KeyEntry(Keys.NumPad8, "8", "*")) Call Add(New KeyEntry(Keys.NumPad9, "9", "(")) Call Add(New KeyEntry(Keys.NumPad0, "0", ")")) '//operations Call Add(New KeyEntry(Keys.Divide, "/", "")) Call Add(New KeyEntry(Keys.Multiply, "*", "")) Call Add(New KeyEntry(Keys.Subtract, "-", "")) Call Add(New KeyEntry(Keys.Add, "+", "")) Call Add(New KeyEntry(Keys.Decimal, ".", ""))I want to create the control using the key handling from the windows because in the future i''ll try to implement the IME.Please, anyone can help me with this challenge. I''m losing all my hairs 解决方案 ", "£")) Call Add(New KeyEntry(Keys.D5, "5", "%", "¢")) Call Add(New KeyEntry(Keys.D6, "6", "¨", "¬")) Call Add(New KeyEntry(Keys.D7, "7", "&")) Call Add(New KeyEntry(Keys.D8, "8", "*")) Call Add(New KeyEntry(Keys.D9, "9", "(")) Call Add(New KeyEntry(Keys.D0, "0", ")")) Call Add(New KeyEntry(Keys.NumPad1, "1", "!", "¹")) Call Add(New KeyEntry(Keys.NumPad2, "2", "@", "²")) Call Add(New KeyEntry(Keys.NumPad3, "3", "#", "³")) Call Add(New KeyEntry(Keys.NumPad4, "4", "", "£")) Call Add(New KeyEntry(Keys.NumPad5, "5", "%", "¢")) Call Add(New KeyEntry(Keys.NumPad6, "6", "¨", "¬")) Call Add(New KeyEntry(Keys.NumPad7, "7", "&")) Call Add(New KeyEntry(Keys.NumPad8, "8", "*")) Call Add(New KeyEntry(Keys.NumPad9, "9", "(")) Call Add(New KeyEntry(Keys.NumPad0, "0", ")")) '//operations Call Add(New KeyEntry(Keys.Divide, "/", "")) Call Add(New KeyEntry(Keys.Multiply, "*", "")) Call Add(New KeyEntry(Keys.Subtract, "-", "")) Call Add(New KeyEntry(Keys.Add, "+", "")) Call Add(New KeyEntry(Keys.Decimal, ".", ""))I want to create the control using the key handling from the windows because in the future i''ll try to implement the IME.Please, anyone can help me with this challenge. I''m losing all my hairsPlease use the event KeyPress as it gives you the character of the letters. It will preserve the system keyboard layouts, so you don''t need to deal with each key separately. Use KeyDown to work with keys on lower level, such as F1, F2, etc.—SA 这篇关于自定义输入控件 - 从头开始​​的文本框(Keyb布局问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 06:00