2

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

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

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

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();
4

3 回答 3

5

我也在寻找隐藏小键盘图标(SIP图标)的解决方案,我通过使用 and 的and FindWindowWorMoveWindow功能SetWindowPos实现了这一点coredll.dlluser32.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. 使用 VB.net 在 Windows Mobile 中禁用键盘图标
  3. 管理 SIP - 跳到这篇文章的底部并查找用户名Mark的评论

编辑

我不得不稍微修改一下才能编译。

    const int SWP_HIDE = 0x0080;
    IntPtr hWnd = FindWindow(null, "MS_SIPBUTTON");
    SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDE);
于 2011-09-05T06:15:33.080 回答
1
[DllImport("coredll.dll", EntryPoint = "SipShowIM")]
public static extern bool SipShowIMP(int code);

SipShowIMP(1); //Show the keyboard

SipShowIMP(0); //Hide the keyboard

应该这样做:-)

于 2011-09-05T06:23:40.623 回答
1

这个答案取自以下文章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);
        }
    }
}
于 2014-03-07T17:21:48.647 回答