防止TouchKeyboard抢占焦点
我用 Delphi 为平板电脑编写了一个小应用程序。所以没有键盘。应用程序中有一个小表单,用户可以在其中输入驱动程序名称。我想在表单上放置一个触摸键盘,但由于表单本身很小,无法容纳虚拟键盘。我可以把键盘的尺寸调小,但那样的话打字会很困难。所以我决定编写另一个仅由键盘组成的应用程序。当主应用程序中的 DBEdit 获得焦点时,我想执行 Touchkeyboard 应用程序,当 DBEdit 失去焦点时,我想关闭 Touchkeyboard 应用程序。我的问题之一是如何防止触摸键盘在启动时抢占焦点。另一个是我如何在主应用程序下显示触摸键盘。提前致谢。
I've written a little app in Delphi for a Tablet PC. So there's no keyboard. And there's a small form in the application where the user can enter driver names. I wanted to put a TouchKeyboard on the form but as the form itself is small it's not possible to accommodate the virtual keyboard. I can make the keyboard's size small but in that case it'll be very difficult to type. So I've decided to write another app that is composed of just a keyboard. When a DBEdit in the main application is focused I want to execute the Touchkeyboard application and when DBEdit loses focus shut down the Touchkeyboard app. One of my questions is how to prevent Touchkeyboard from grabbing focus on launch. And the other one is how I can display the Touchkeyboard just under the main application. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不需要其他应用程序。只需创建另一种形式,这样您就可以更好地处理焦点和隐藏。我不确定你的应用程序“就在”之下是什么意思,但我想你的意思是窗口的位置应该在应用程序窗口的下方。请参阅以下代码片段:
有 2 种形式:MainForm 和 KeyboardForm。
...
这基本上就是处理显示/隐藏表单所需的全部内容。由于 KeyboardForm 不会在启动时显示,因此它不会获得焦点(除非 Edit 将 TabOrder 设置为 0 并且 TabStop 设置为 true - 然后 OnEnter 事件会在应用程序启动时触发)。
工作原理
注意:可以使用 SendInput() 代替 keybd_event。
You don't need another app. Just create another form, that way you can work with focuses and hiding better. I am not sure what you mean by "just under" your app, but I suppose you mean the position of the window should be below the application window. See this snippet:
There are 2 forms: MainForm and KeyboardForm.
...
And this is basically all you need to handle showing/hiding the form. Since the KeyboardForm is not shown on-start, it doesn't take focus, (unless the Edit has TabOrder set to 0 with TabStop true - then the OnEnter event fires with the start of the application).
How it works
Note: SendInput() can be used instead of keybd_event.
有关虚拟键盘设计的非常有趣的文章和讨论,请参阅 http://www.virtual-keyboard-design.com
for very interesting articles and discussion around virtual keyboard design, see http://www.virtual-keyboard-design.com
回复我成功尝试提供 Delphi 键盘可能会引起兴趣。
Responses to my successful attempt to provide a Delphi keyboard may be of interest.