如何在Windows Mobile 6.5中隐藏小键盘弹出窗口? (C#)

时间:2011-09-03 02:10:18

标签: c# windows-mobile-6.5

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

在图片功能被取消后,小键盘图标显示出来(不方便地覆盖了我的一个向导按钮)。

我尝试通过调用:

将覆盖的窗口设置为fron
nextButton.BringToFront();

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

注意 - 它不是软键盘 - 但是用户点击的图像会带来这一点。

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

修改

鉴于两个人非常有信心他们的代码可以工作,并且在线查看参考文献我认为他们可能是对的我想我会详细说明这个问题,因为这两个建议都没有解决问题。

在“拍照”/ CameraCaptureDialog中选择菜单上的取消或确定按钮后,键盘项似乎是遗留下来的剩余部分。

在退出对话框时,我似乎剩下中间/键盘菜单项,我似乎无法做任何事情。

以下是模拟器中的样子(也发生在模拟器上) enter image description here

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

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

3 个答案:

答案 0 :(得分:5)

我也在寻找隐藏小键盘图标(SIP图标)的解决方案,我使用FindWindowWMoveWindowSetWindowPos coredll.dll函数来实现这一目标}和user32.dll

声明我们感兴趣的功能:

    [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 - 跳到这篇文章的底部并寻找 用户名标记
  4. 的评论

    修改

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

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

答案 1 :(得分:1)

[DllImport("coredll.dll", EntryPoint = "SipShowIM")]
public static extern bool SipShowIMP(int code);

SipShowIMP(1); //Show the keyboard

SipShowIMP(0); //Hide the keyboard

应该这样做: - )

答案 2 :(得分:1)

这个答案取自以下文章http://beemobile4.net/support/technical-articles/windows-mobile-programming-tricks-on-net-compact-framework-12(我只添加了使用声明)。我使用的是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);
        }
    }
}