2

I'm implementing a custom IEnumString to be used as a dataset for an IAutoComplete2 object.

The problem is that IAutoComplete2 appears to only call reset on my IEnumString when the first character is entered in an editbox and then relies on the fact that the dataset remains static (and doing local filtering after that) during subsequent key presses.

I tried to remove the IAutoComplete2 object and then immedietely creating a new one and attaching it to the control, but this lead to a crash in shell32.

Is this even possible?

monoceres
  • 4,722
  • 4
  • 38
  • 63
  • 1
    Have you considered implementing [IACList](http://msdn.microsoft.com/en-us/library/windows/desktop/bb776378%28v=vs.85%29.aspx) for your enumerator? I must admit that I don't understand why you want to reset the enumeration while the user is typing. – Eric Brown Sep 13 '13 at 16:46
  • I did not know about IACList, I will look it up. Because I'm executing a sql query with a small limit. The lookup is from a very large table (>250k rows) so the entire set cannot be returned with the first character input as a critieria only. – monoceres Sep 13 '13 at 17:56
  • Looking a bit more, I think the relevant interface is actually [IAutoCompleteDropDown](http://msdn.microsoft.com/en-us/library/windows/desktop/bb776286(v=vs.85).aspx) - it has an explicit ResetEnumerator method that gets called in several places. IACList seems to be specifically for directory enumeration. – Eric Brown Sep 13 '13 at 18:46
  • Also, does this need to be run from within a generic edit control, or is this hosted in some other environment? – Eric Brown Sep 13 '13 at 18:49
  • It's for generic edit controls found throughout our software suite. IAutoCompleteDropDown seems to be the correct thing. Documentation and examples seems spars though, how do you receive an object to call the ResetEnumerator on for example? – monoceres Sep 13 '13 at 19:30
  • You `QueryInterface` for it off the same object that implements `IAutoComplete[2]`. – Igor Tandetnik Sep 13 '13 at 19:48
  • `IACList` is not specific to directories. The OS provides a default `IACList` implementation for the filesystem, but you can certainly implement `IACList` in your own classes as well. – Remy Lebeau Sep 13 '13 at 20:04

1 Answers1

2

When you want to reset the enumeration, you should QueryInterface your IAutoComplete interface for IAutoCompleteDropDown and then call ResetEnumerator.

Creation:

    CComPtr<IAutoComplete> m_spAutoComplete;

    CHECKHR(CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_spAutoComplete)));

When you want to reset the enumeration:

    CComPtr<IAutoCompleteDropDown> spAutoCompleteDD;
    CHECKHR(m_spAutoComplete->QueryInterface(IID_PPV_ARGS(&spAutoCompleteDD)));
    CHECKHR(spAutoCompleteDD->ResetEnumerator()); 
Eric Brown
  • 13,774
  • 7
  • 30
  • 71