I have an app that is essentially a wizard that goes through some dialog boxes. One of the forms has just a button on it that brings up the common \"take picture\" dialog.
This answer was taken from the following article http://beemobile4.net/support/technical-articles/windows-mobile-programming-tricks-on-net-compact-framework-12 (I have only added the using statements). I'm on 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
That should do it :-)
I was also looking for the solution to hide the small keyboard icon (SIP icon) and I achieved this by using the FindWindowW
and MoveWindow
or SetWindowPos
functions of coredll.dll
and user32.dll
Declare the function we are interested in:
[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);
Then find the handle to keyboard icon and call the SetWindowPos
to hide it:
IntPtr hWnd = FindWindow(Nothing, "MS_SIPBUTTON");
SetWindowPos(hWnd, 1, 0, 0, 0, 0, &H80);
Useful links:
EDIT
I had to modify this slightly to compile.
const int SWP_HIDE = 0x0080;
IntPtr hWnd = FindWindow(null, "MS_SIPBUTTON");
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDE);