I'm trying to move the keyboard to the bottom of the screen to hide the 35px menu bar that it shows by d开发者_高级运维efault on windows mobile 5/6. All of the examples I've seen about modifying the menu bar deal with hiding the button "MS_SIPBUTTON". The two parts of my question are:
How can I move the keyboard down 35 pixels on the screen?
And, where is "MS_SIPBUTTON" defined?
Part one:
The best way I could muster to move the keyboard was a collection of Windows API calls all referenced from pinvoke.net
First a bunch of DllImport statements:
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string caption, string className);
[DllImport("coredll.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[DllImport("coredll.dll")]
internal static extern void MoveWindow(IntPtr hwnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport("coredll.dll", SetLastError = true)]
extern static int SipShowIM(int dwFlag);
Next some constants and variables:
Rectangle sipbutton;
Rectangle keyboardBackground;
Rectangle keyboard;
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
private const int GW_CHILD = 5;
private const int SIPF_ON = 1;
private const int SIPF_OFF = 0;
Functions for showing and hiding the SIP button that displays at the bottom of the page. They are called in my constructor and destructor
public void HideSip()
{
IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
if (hTaskBarWindow != IntPtr.Zero)
{
RECT rct;
if (!GetWindowRect(hTaskBarWindow, out rct))
{
MessageBox.Show("ERROR");
return;
}
Rectangle myRect = new Rectangle();
myRect.X = (int)rct.Left;
myRect.Y = (int)rct.Top;
myRect.Width = (int)(rct.Right - rct.Left + 1);
myRect.Height = (int)(rct.Bottom - rct.Top + 1);
//save previous state
sipbutton = myRect;
MoveWindow(hTaskBarWindow, myRect.X, myRect.Y + 1000, myRect.Width, myRect.Height, true);
//MoveWindow(hTaskBarWindow, 100, 100, 100, 100, true);
}
}
public void RestoreSip()
{
IntPtr hTaskBarWindow = FindWindow("MS_SIPBUTTON", null);
if (hTaskBarWindow != IntPtr.Zero && sipbutton.Height > 0 && sipbutton.Width > 0)
{
MoveWindow(hTaskBarWindow, sipbutton.X, sipbutton.Y, sipbutton.Width, sipbutton.Height, true);
}
}
With that out of the way we need to move the keyboard down to the bottom of the screen:
public void MoveKeyboardDown(int pixelsDown)
{
IntPtr hSipWindow = FindWindow("SipWndClass",null);
if (hSipWindow != IntPtr.Zero)
{
RECT rct;
if (!GetWindowRect(hSipWindow, out rct))
{
MessageBox.Show("ERROR");
return;
}
Rectangle myRect = new Rectangle();
myRect.X = (int)rct.Left;
myRect.Y = (int)rct.Top;
myRect.Width = (int)(rct.Right - rct.Left + 1);
myRect.Height = (int)(rct.Bottom - rct.Top + 1);
//save previous state
keyboard = myRect;
MoveWindow(hSipWindow, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);
}
IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass",null);
if (hSipWindow2 != IntPtr.Zero)
{
RECT rct;
if (!GetWindowRect(hSipWindow2, out rct))
{
MessageBox.Show("ERROR");
return;
}
Rectangle myRect = new Rectangle();
myRect.X = (int)rct.Left;
myRect.Y = (int)rct.Top;
myRect.Width = (int)(rct.Right - rct.Left + 1);
myRect.Height = (int)(rct.Bottom - rct.Top + 1);
//save previous state
keyboardBackground = myRect;
MoveWindow(hSipWindow2, myRect.X, myRect.Y + pixelsDown, myRect.Width, myRect.Height, true);
}
arPages[iCurrentPage].Invalidate();
}
public void RestoreKeyboard()
{
IntPtr hSipWindow = FindWindow("SipWndClass", null);
if (hSipWindow != IntPtr.Zero && keyboard.Height > 0 && keyboard.Width > 0)
{
MoveWindow(hSipWindow, keyboard.X, keyboard.Y, keyboard.Width, keyboard.Height, true);
}
IntPtr hSipWindow2 = FindWindow("SipBackDropWndClass", null);
if (hSipWindow2 != IntPtr.Zero && keyboardBackground.Height > 0 && keyboardBackground.Width > 0)
{
MoveWindow(hSipWindow2, keyboardBackground.X, keyboardBackground.Y, keyboardBackground.Width, keyboardBackground.Height, true);
}
}
When you want to show the keyboard do some thing like this:
SipShowIM(SIPF_ON);
MoveKeyboardDown(25);
When you want to hide it do this:
SipShowIM(SIPF_OFF);
RestoreKeyboard();
Part two:
I was able to discover the names of windows referenced above using CE Remote Tools/Windows CE Remote Spy. The executable is "ccspy.exe"
精彩评论