Delphi 2010 平板电脑支持
当我因工作需要购买 delphi 时,我看到的一大卖点是它支持平板电脑的能力。现在我工作的公司的客户想要使用平板电脑。我一直在努力寻找 delphi 与平板电脑的示例,但我没有找到。有人有这方面的经验吗?有任何类型的教程或示例吗?
当组件获得焦点时我什至无法带上虚拟键盘并在失去焦点时隐藏它。
One of the big selling points I saw when I had to buy delphi for my job was the ability to support tablet pc's. Now the client of the company where I work want to use a tablet pc. I've been trying hard to find examples of delphi with tablet pc but I don't find any. Does anybody has experience with it? Any kind of tutorials or examples?
I don't seem to be able even to bring a virtual keyboard when a component gain focus and hide it when it loses it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Delphi 2010 为 Delphi 引入了一些很好的触摸和手势支持。
要获取更多信息,请访问 EDN 网站并查找 CodeRage 4 重播。 Seppy Bloom 举办了一场题为“VCL 中的手势”的会议。 CodeRage 5 中还有一个题为“新应用程序和当前项目的手势功能”的会议,作者为 Vesvolod Leonov。
Marco Cantu 的“Delphi 2010 手册”第 6 章也介绍了 Delphi 中的触摸和手势。
最后,您可以查看 Chris Bensen 的博客,了解一些介绍性帖子和演示源代码Delphi 中的触摸和手势支持。
在 Delphi 2010 及更新版本中,支持触摸的键盘组件是已经可用。要使其在焦点更改时可见或隐藏,您可以处理 CM_FOCUSCHANGED VCL消息,当获得焦点的控件派生于某个类或满足某些特殊条件时,使键盘可见。以下是示例代码:
每次焦点更改时,上面的代码都会调用ActivateVirtualKeyboard。 Msg.Sender 是获得焦点的控件。 ActivateVirtualKeyboard 检查该控件是否是 TCustomEdit 后代(如 TEdit 或 TMemo 之类的组件源自此类)。如果该控件派生自 TCustomEdit,则它将虚拟键盘放置在该控件的正下方,并使键盘可见;否则,它会隐藏键盘。
在示例代码中,Form1 上有一个编辑、一个备忘录和一个按钮。键盘对于 Edit1 和 Memo1 应该可见,而当 Button1 获得焦点时键盘应该隐藏。
屏幕上键盘位置的计算并不那么聪明,如果具有焦点的控件非常接近窗体的底部边缘,键盘可能会太向下。无论如何,在屏幕上定位控件超出了您的问题范围。
Delphi 2010 introduced some nice touch and gesture support to Delphi.
To get more info about it, go to EDN website and look for CodeRage 4 replays. There is a session titled "Hands on gestures in VCL" by Seppy Bloom. Also in CodeRage 5 there is a session titled "Gesturing Capabilities for New Application and Current Projects" by Vesvolod Leonov.
Chapter 6 of Marco Cantu's "Delphi 2010 Handbook" also covers touch and gesture in Delphi.
Eventually, you can check Chris Bensen's weblog for some introductory posts and demo source code about touch and gesture support in Delphi.
In Delphi 2010 and newer versions a touch-enabled keyboard component is already available. To make it is visible or hide it when focus is changed, you can handle CM_FOCUSCHANGED VCL message, and make the keyboard visible when the control gaining focus is derived from a certain class or meets some special conditions. Here is a sample code:
The code above calls ActivateVirtualKeyboard each time focus is changed. Msg.Sender is the control which gained focus. ActivateVirtualKeyboard checks if the control is a TCustomEdit descendant (components like TEdit or TMemo descend from this class). If the control is derived from TCustomEdit, then it places virtual keyboard right beneath the control, and makes the keyboard visible; otherwise, it hides the keyboard.
In the sample code we have an edit, a memo, and a button on Form1. The keyboard should be visible for Edit1 and Memo1, and hid when Button1 has focus.
The calculation for keyboard position on the screen isn't that clever, and keyboard might go too down if the control having focus is very close to the bottom edge of the form. Anyway, positioning a control on the screen is out of the scope of your question.