[英]How can I hide the little keyboard popup in Windows Mobile 6.5? (c#)
我有一个本质上是一个向导的应用程序,它会通过一些对话框。 其中一种表格上只有一个按钮,它会弹出常见的“拍照”对话框。
取消图片功能后,将显示小键盘图标(不方便地覆盖了我的一个向导按钮)。
我尝试通过调用将覆盖的窗口设置为fron:
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();
我也在寻找隐藏小键盘图标(SIP图标)的解决方案,并通过使用coredll.dll
和user32.dll
的FindWindowW
和MoveWindow
或SetWindowPos
函数实现了此目的。
声明我们感兴趣的功能:
[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);
有用的链接:
编辑
我不得不对此稍作修改以进行编译。
const int SWP_HIDE = 0x0080;
IntPtr hWnd = FindWindow(null, "MS_SIPBUTTON");
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDE);
此答案来自以下文章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);
}
}
}
[DllImport("coredll.dll", EntryPoint = "SipShowIM")]
public static extern bool SipShowIMP(int code);
SipShowIMP(1); //Show the keyboard
SipShowIMP(0); //Hide the keyboard
应该这样做:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.