Google喜欢Delphi编辑/组合控件? [英] Google like edit/combo control for Delphi?

查看:139
本文介绍了Google喜欢Delphi编辑/组合控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人都可能知道我的意思,但要澄清控制需要:

Everyone probably knows what I mean, but to clarify the control would need to:


  • 用户编辑文本时触发事件。该事件将提供一个SuggestionList:TStrings,您可以填写匹配/建议。

  • 如果SuggestionList不为空,则会出现一个下拉列表。

  • 与组合不同,控件不应该尝试自动选择/自动完成或以其他方式影响编辑。

那么,是否有一个Delphi编辑/组合控件的作用如下?

So, is there a Delphi edit/combo control that works like that ?

推荐答案

使用自动完成功能内置到所有Windows编辑控件。

Use the autocompletion feature built in to all Windows edit controls.

首先,填写你的 TStrings 对象,但是你想要的。然后使用 GetOleStrings 创建一个 TStringsAdapter 包装它(适配器不声明对 TStrings 对象的所有权,所以您必须确保在适配器仍然存在时不要销毁它。)适配器为您提供 IStrings 界面,您需要它,因为自动完成功能需要一个 IEnumString 界面提供完成匹配。致电 _NewEnum

First, fill your TStrings object however you want. Then use GetOleStrings to create a TStringsAdapter to wrap it. (The adapter does not claim ownership of the TStrings object, so you must make sure you don't destroy it while the adapter is still live.) The adapter gives you an IStrings interface, which you'll need because the autocompletion feature requires an IEnumString interface to provide the completion matches. Call _NewEnum for that.

接下来,调用 CoCreateInstance 来创建一个 IAutoComplete 对象。调用其 Init 方法将其与编辑控件的窗口句柄相关联。如果您使用组合框,请发送一个 cbem_GetEditControl 消息以找到底层的编辑窗口。

Next, call CoCreateInstance to create an IAutoComplete object. Call its Init method to associate it with the window handle of your edit control. If you're using a combo box, then send it a cbem_GetEditControl message to find the underlying edit window.

您可以停止在这一点,自动完成应该自动工作。您可以根据需要禁用自动完成功能,也可以设置任意数量的自动完成选项< a>。

You can stop at that point and autocompletion should work automatically. You can disable autocompletion if you want, or you can set any number of autocompletion options.

你说你不想要自动完成,但在操作系统术语中,我认为你真正不想要的是 auto append ,其中字符串的其余部分在用户键入时自动输入到编辑框中,但被选中,以便进一步输入将覆盖它,并且如果期望值短于其中之一,则用户需要删除多余的文本比赛。

You say you don't want autocompletion, but in the OS terminology, I think what you really don't want is called auto append, where the remainder of the string is entered into the edit box automatically as the user types, but selected so that further typing will overwrite it, and the user needs to delete the excess text if the desired value is shorter than one of the matches.

还有自动建议,显示一个下拉列表的建议。

There is also auto suggest, which displays a drop-down list of suggestions.

您可以启用这两个选项。您不需要自己过滤建议列表;自动填充对象本身将过滤 IEnumString 列表。

You can enable either or both options. You don't need to filter the list of suggestions yourself; the autocomplete object filters the IEnumString list by itself.

这篇关于Google喜欢Delphi编辑/组合控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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