【问题标题】:How can I hide the little keyboard popup in Windows Mobile 6.5? (c#)如何在 Windows Mobile 6.5 中隐藏小键盘弹出窗口? (C#)
【发布时间】:2011-09-03 02:10:17
【问题描述】:

我有一个应用程序,它本质上是一个通过一些对话框的向导。其中一个表单上只有一个按钮,可以打开常见的“拍照”对话框。

关闭图片功能后,小键盘图标出现(不方便地覆盖了我的一个向导按钮)。

我尝试通过调用将覆盖的窗口设置为正面:

nextButton.BringToFront();

但这没有任何效果。我需要以某种方式禁用小键盘图标,但不知道该怎么做。

注意 - 不是软键盘 - 而是用户单击的图像会显示它。

注意 - 此表单上没有文本控件 - 只有 4 个按钮 - 一个用于启动 CameraCaptureDialog,还有一些用于控制用户进入“下一个”和“上一个”屏幕。

编辑

鉴于两个人非常有信心他们的代码可以运行,并且查看网上的参考资料,我认为他们可能是对的,我想我会详细说明这个问题,因为这两个建议都不能解决问题。

在“拍照”/CameraCaptureDialog 的菜单上选择取消或确定按钮后,键盘项目似乎是一个残留物。

退出对话框时,我似乎留下了中间/键盘菜单项,我似乎无能为力。

这是它在模拟器中的样子(也发生在模拟器上)

注意 - 调用以下所有对隐藏按钮的键盘图标没有影响:

// nextButton is the Button on the control hidden by the keyboard icon thingy
nextButton.Focus();
nextButton.BringToFront();
nextButton.Invalidate();
nextButton.Refresh();
nextButton.Show();

【问题讨论】:

    标签: c# windows-mobile-6.5


    【解决方案1】:

    我也在寻找隐藏小键盘图标(SIP 图标)的解决方案,我通过使用 coredll.dlluser32.dllFindWindowWMoveWindowSetWindowPos 函数实现了这一目标

    声明我们感兴趣的函数:

        [DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
        [DllImport("coredll.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
    

    然后找到键盘图标的句柄并调用SetWindowPos将其隐藏:

    IntPtr hWnd = FindWindow(Nothing, "MS_SIPBUTTON");
    SetWindowPos(hWnd, 1, 0, 0, 0, 0, &H80);
    

    有用的链接:

    1. P/Invoke - coredll.dll
    2. Disable keyboard icon in Windows Mobile using VB.net
    3. Manage SIP - 跳到这篇文章的底部并寻找 用户名 Mark 的 cmets

    编辑

    我必须稍微修改一下才能编译。

        const int SWP_HIDE = 0x0080;
        IntPtr hWnd = FindWindow(null, "MS_SIPBUTTON");
        SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDE);
    

    【讨论】:

    • 是的,我在这里发布的解决方法是隐藏图标而不是实际的键盘,MS_SIPBUTTON 指的是那个按钮图标
    • 好的,我明白了,谢谢。尽管在调用引用的代码中出现异常。这就是为什么我想象它不起作用。不知道为什么会这样。我必须做一些特别的事情才能让它们发挥作用吗?
    • user32 名称必须更改为 coredll,我认为它可以工作。
    • 很好,我正在尝试制作一个示例项目,但由于某种原因,我的 VS 不允许为智能设备添加项目......但是很好,您的问题似乎已经解决了
    • 感谢您的帮助。我很感激。我接受了答案 - 当我可以在设备上部署和测试时,我将奖励赏金。它适用于模拟器。
    【解决方案2】:
    [DllImport("coredll.dll", EntryPoint = "SipShowIM")]
    public static extern bool SipShowIMP(int code);
    
    SipShowIMP(1); //Show the keyboard
    
    SipShowIMP(0); //Hide the keyboard
    

    应该这样做:-)

    【讨论】:

      【解决方案3】:

      这个答案取自以下文章http://beemobile4.net/support/technical-articles/windows-mobile-programming-tricks-on-net-compact-framework-12(我只添加了using语句)。我使用的是 Windows Mobile 6.1 Classic、.NET CF 3.5。

      using System;
      using System.Runtime.InteropServices;
      
      [DllImport("coredll.dll", SetLastError = true)]
      private static extern IntPtr FindWindow(string caption, string className);
      
      [DllImport("coredll.dll", SetLastError = true)]
      private static extern bool ShowWindow(IntPtr hwnd, int state);
      
      [DllImport("coredll.dll")]
      private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
      
      private const int SW_HIDE = 0;
      private const int SW_SHOW = 1;
      private const int GW_CHILD = 5;
      
      ///         
      /// Shows the SIP (Software Input Panel) button.        
      ///
      static public void ShowHideSIP(int nShowOrHide)
      {
          IntPtr hSipWindow = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON");
          if (hSipWindow != IntPtr.Zero)
          {
              IntPtr hSipButton = GetWindow(hSipWindow, GW_CHILD);
              if (hSipButton != IntPtr.Zero)
              {
                  bool res = ShowWindow(hSipButton, nShowOrHide);
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2013-02-04
        • 2014-08-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-01
        • 2013-04-30
        • 2022-12-31
        相关资源
        最近更新 更多