WinCE ARM输入虚拟键盘

时间:2014-01-20 12:37:20

标签: c# compact-framework windows-ce inputstream keyboard-events

我想在点击文本框时显示虚拟键盘。任何想法如何实现我的应用程序的虚拟键盘? 这段代码什么都不做。

    private void textBox1_GotFocus(object sender, EventArgs e)
    {
        inputPanel1.Enabled = true;
    }

    private void textBox1_LostFocus(object sender, EventArgs e)
    {
        inputPanel1.Enabled = false;
    }

1 个答案:

答案 0 :(得分:1)

LostFocus处理程序删除帮助。

我不得不改变键盘的位置。这是唯一可以做到这一点的非现有财产:// ..也许这对某人有用。

    [DllImport("coredll.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SipGetInfo(
        ref SIPINFO sipInfo);

    [DllImport("coredll.dll", SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SipSetInfo(
        ref SIPINFO sipInfo);
    [StructLayout(LayoutKind.Sequential)]

    public struct SIPINFO
    {
        public uint cbSize;
        public uint fdwFlags;
        public RECT rcVisibleDesktop;
        public RECT rcSipRect;
        public uint dwImDataSize;
        public IntPtr pvImData;
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public int left;
        public int top;
        public int right;
        public int bottom;
    }

    private void ShowInputPanel(Control control)
    {
        InputPanel.SIPINFO sipInfo;
        var x = 100;
        var y = control.PointToScreen(new Point(110, 150)).Y;            //control.Height

        this.inputPanel1.Enabled = true;

        sipInfo = new InputPanel.SIPINFO();
        sipInfo.cbSize = (uint)Marshal.SizeOf(sipInfo);
        if (InputPanel.SipGetInfo(ref sipInfo))
        {
            sipInfo.rcSipRect.left = x;
            sipInfo.rcSipRect.top = y;

            InputPanel.SipSetInfo(ref sipInfo);
        }
    }

    private void textBox1_GotFocus(object sender, EventArgs e)
    {
        this.ShowInputPanel(this.textBox1);        
    }