【问题标题】:WinCE ARM input virtual keyboardWinCE ARM 输入虚拟键盘
【发布时间】:2014-02-09 15:27:14
【问题描述】:

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

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

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

【问题讨论】:

  • Enabled 仅在控件响应事件时切换。也许你想要Visible 属性?
  • 那些实际的事件处理程序是附加到事件上的,还是你只是paste the code
  • 我只是粘贴代码,但现在我将它们附加到事件中,但它只显示一秒钟然后关闭
  • @franzp 尝试删除 LostFocus 处理程序。
  • @franzp 启用键盘可能会暂时将焦点从文本框上移开。

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


【解决方案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);        
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-18
    • 1970-01-01
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    相关资源
    最近更新 更多