In my MFC application, I am trying to offer help to users by proposing text as the user types.
The text the user is typing is left as typed, and the proposed text at the end is selected so the user can just hit delete if it is not what they want, or they can keep typing and my proposed test gets closer and closer to what they want.
My code (in a change handler for the CEdit control) looks like this :-
[Code to retrieve the current text]
[Code to get proposed text from my database back end]
(The user's text and the trailing extra proposed text are now in m_Eqpt)
m_EqptCtrl.SetWindowTextW(m_Eqpt);
m_EqptCtrl.SetSel(nTextLength, m_Eqpt.GetLength());
(nTextLength is the length of the text the user entered)
This works great as the user is typing, but if the user back-spaces or hilights and deletes text, my code is repeatedly adding the proposed text back in, where it should leave it alone at this point.
I'm at a loss to see how I can determine if the user has deleted my proposed text. Anyone solved a similar problem?
Is the Shell autocomplete a way to solve your problem?
Here the MSDN description for the Shell code
Here another code sample from CodeProject, that should use a similar Approach than you do.