2

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.

After that picture functionality is dismissed the little keyboard icon shows up (inconveniently covering over one of my wizard buttons).

I tried setting the covered window to the fron by calling:

nextButton.BringToFront();

But that has no effect. I need to disable the little keyboard icon somehow and not sure how to do it.

Note - it is not the soft keyboard - but the image that the user clicks that will bring that up.

Note - there are no text controls on this form - there are only 4 buttons - one that initiates the CameraCaptureDialog, and a few others that control the user going to the "next" and "previous" screens.

EDIT

Given that two people were very confident their code would work, and looking at the references online I figured they might be right I figured I would elaborate on the issue since neither suggestions fix the problem.

The keyboard item seems to be a remnant left over after I select either the cancel or OK button on the menu in the "take picture"/CameraCaptureDialog.

On exiting the Dialog I seem to have the middle/keyboard menu item left over and there is nothing I seem to be able to do about it.

Here is what it looks like in the emulator (happens on emulator as well) enter image description here

Note - calling all the following have NO effect on the keyboard icon thingy hiding the button:

// nextButton is the Button on the control hidden by the keyboard icon thingy
nextButton.Focus();
nextButton.BringToFront();
nextButton.Invalidate();
nextButton.Refresh();
nextButton.Show();
Tim
  • 20,184
  • 24
  • 117
  • 214

3 Answers3

5

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:

  1. P/Invoke - coredll.dll
  2. Disable keyboard icon in Windows Mobile using VB.net
  3. Manage SIP - skip to the bottom on this post and look for comments of user name Mark

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);
xsl
  • 17,116
  • 18
  • 71
  • 112
Waqas
  • 6,812
  • 2
  • 33
  • 50
  • Yes, the work around i posted here is about hiding the icon not the actual keyboard and MS_SIPBUTTON refers to that button icon – Waqas Sep 08 '11 at 04:48
  • OK, I see, thanks. I get exceptions though in the code for calling the references. That is why it does not work I imagine. Not sure why that would happen. Do I have to do anything special to get those to work? – Tim Sep 08 '11 at 14:41
  • The user32 names have to be changed to coredll and I think it works. – Tim Sep 08 '11 at 19:36
  • nice, i was trying to make a sample project but for some reason my VS wasn't allowing to add project for smart devices... but good that your problem seems to be solved – Waqas Sep 08 '11 at 19:48
  • thanks for the help. I appreciate it. I accepted the answer - I will award the bounty when I can deploy and test on the device. It works for the emulator. – Tim Sep 08 '11 at 19:49
  • So this only hides SIP button ? Keyboard stays in the same position ? – IvanP Mar 24 '16 at 15:35
1

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);
        }
    }
}
cyber-monk
  • 5,470
  • 6
  • 33
  • 42
1
[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 :-)

Varun Chatterji
  • 5,059
  • 1
  • 23
  • 24