Windows Mobile 6 - Disable AutoComplete on WinForms TextBoxes

怎甘沉沦 提交于 2019-12-18 03:48:16

问题


I am making a windows mobile 6 app, where I need to disable autocomplete on the textboxes that I have on my form. Information is being scanned into them, therefore I need to disable the autocomplete/autosuggest feature. Can I do this programmatically or do I need to manipulate registry keys? (This is not a commercial application.)


回答1:


Use this class, it will pinvoke the SHSetInputContext method and disable\enable the hover over events for the controls. Simply pass the controls Handle.

public static class InputContext
{
    private enum SHIC_FEATURE : uint
    {
        RESTOREDEFAULT = 0,
        AUTOCORRECT = 1,
        AUTOSUGGEST = 2,
        HAVETRAILER = 3,
        CLASS = 4
    }

    [DllImport("aygshell.dll")]
    private static extern int SHSetInputContext(IntPtr hwnd, SHIC_FEATURE dwFeature, ref bool lpValue);

    public static void SetAutoSuggestion(IntPtr handle, bool enable)
    {
        SHSetInputContext(handle, SHIC_FEATURE.AUTOSUGGEST, ref enable);
        SHSetInputContext(handle, SHIC_FEATURE.AUTOCORRECT, ref enable);
    }
}

Example:

InputContext.SetAutoSuggestion(txtBoxOne.Handle, false);


来源:https://stackoverflow.com/questions/4548077/windows-mobile-6-disable-autocomplete-on-winforms-textboxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!