谷歌像德尔福编辑/组合控制? [英] Google like edit/combo control for Delphi?

查看:108
本文介绍了谷歌像德尔福编辑/组合控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家可能知道我的意思,而是要澄清的控制将需要:

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


  • 当用户编辑文本触发事件。本次活动将提供一个SuggestionList:字符串列表,你可以用火柴/建议填写

  • 如果该SuggestionList不为空下拉应该会出现。

  • 与组合,控制不应试图自动选择/自动完成或影响编辑。

那么,有没有工作方式类似于一个德尔福编辑/组合控制?

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

推荐答案

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

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

第一,但是你想填补你的字符串列表对象。然后使用 GetOleStrings 来创建一个<一个href=\"http://docwiki.embarcadero.com/VCL/en/AxCtrls.TStringsAdapter\"><$c$c>TStringsAdapter把它包起来。 (适配器不主张字符串列表对象的所有权,所以你必须确保你不破坏它,而适配器仍然活着。)该适配器为您提供了一个 IStrings 界面,你需要,因为自动完成功能需要的 IEnumString 接口,提供完成比赛。呼叫<一个href=\"http://docwiki.embarcadero.com/VCL/en/AxCtrls.TStringsAdapter._NewEnum\"><$c$c>_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 对象。调用其 初始化 方法将其关联与你的编辑控件的窗口句柄。如果您使用的是组合框,然后发送一个 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.

您可以在这一点上停下来,自动完成应自动工作。如果你愿意,你可以禁用自动完成,也可以设置任意数量的自动完成选项

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.

你说你不想自动完成,但是在操作系统术语,我觉得你真的不希望被称为自动追加什么,其中字符串的其余部分被输入到编辑自动框作为用户类型,但是选择以便进一步分型将覆盖它,用户需要删除多余的文本,如果期望的值大于比赛之一短。

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.

这篇关于谷歌像德尔福编辑/组合控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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