在控件进入和离开时自动开启、关闭中文输入法

[DllImport("user32")]
        private static extern uint ActivateKeyboardLayout(uint hkl, uint Flags);




private void comboboxEdit_Enter(object sender, EventArgs e)
        {
            InitData(sender);
            try
            {
                ActivateKeyboardLayout(1, 1);
            }
            catch (Exception ex)
            {
            }
        }

        private void comboboxEdit_Leave(object sender, EventArgs e)
        {
            try
            {
                ActivateKeyboardLayout(0, 1);
            }
            catch (Exception ex)
            {
            }
        }

posted @ 2007-08-13 14:55  禹过天晴  阅读(350)  评论(0编辑  收藏  举报