0

I am using IAutoComplete2 for updating a text box. This is the code I'm using to create the IAutoComplete2:

lstSource:= TStringList.Create;
lstSource.LoadFromFile('source.txt');
FAutoSource  := CreateComObject(CLSID_AutoComplete) as IAutoComplete2;
FStringsSource := TEnumString.Create(lstSource) as IUnknown;
OleCheck(FAutoSource.SetOptions(ACO_AUTOAPPEND));
OleCheck(FAutoSource.Init(txtText.Handle, FStringsSource, nil, nil));  

This is working fine, but I need to update the source list if the user types in something that isn't already in the list. I am adding the new string to lstSource; how do I then update FStringsSource?

Nimusi

2
  • TEnumString has a reference to lstSource, so it can already see the new strings you add to it. If you are adding the strings to the end of the list, FStringsSource.Next() should see them automatically the next time it is called by the Edit control. Otherwise, try calling FStringsSource.Reset() to reset the enumeration back to the beginning of the list each time you modify it. If that still does not work, you may have to re-Init() the Edit control Jul 10, 2019 at 16:34
  • Thanks @Remy. Following your suggestion I've been experimenting with this. The solution seems to be to recreate the FAutoSource and FstringsSource objects and then re-Init FAutoSource.
    – NiMuSi
    Jul 11, 2019 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.