Skip to content

Instantly share code, notes, and snippets.

@zaxbux
Created June 13, 2019 08:57
Show Gist options
  • Save zaxbux/62b8ea44b82a8e16ad126643b2a44fca to your computer and use it in GitHub Desktop.
Save zaxbux/62b8ea44b82a8e16ad126643b2a44fca to your computer and use it in GitHub Desktop.
Toggle the visibility of the Soft Input Panel button on Windows CE Mobile
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Toggle the visibility of the Soft Input Panel button
/// Source: http://beemobile4.net/support/technical-articles/windows-mobile-programming-tricks-on-net-compact-framework-12
/// </summary>
namespace SoftwareInputPanel
{
class Button
{
[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 private void ShowHide(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);
}
}
}
/// <summary>
/// Show the SIP button
/// </summary>
static public void Show()
{
ShowHide(SW_SHOW);
}
/// <summary>
/// Hide the SIP button
/// </summary>
static public void Hide()
{
ShowHide(SW_HIDE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment