• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2178
  • Last Modified:

Change hardware keyboard layout from CF.net


I'm developing a CF.Net application.
In it I have several textboxes for numeric input only.

The problem is that when ever the user uses the hardware keyboard (which has a 10 digit numeric layout), it always inserts text into the textbox...
Eg. typing 3 inserts a 'd'

I have tried....
InputModeEditor.SetInputMode(this.txtSomeNumber, InputMode.Numeric);
... It does not work.

Though, if the users holds down the * a small list appears, where the users can choose between T9, ABC or 123 (Numeric)
If the user chooses 123, then the hardware keyboard inputs numeric values.

I want to be able to programmatically set the hardware keyboard to 123 or ABC
There has to be some p/invoke or likewise that can do this.... but how?

Device: HP iPaq 614c
OS: Windows Mobile 6 Professional
Runtime: Compact Framework 2.0

Thank you!
  • 3
1 Solution
tarasbredelAuthor Commented:
Hi Mikal

SIP = software-based input panel
The link you sent me is how to show/hide the SIP, and which InputMethods it has.

Even though I change the SIP to be numeric, it does not effect the hardware-based keyboard, which is still alpha.

I need to change to output from the hardware-based keyboard to numeric.

tarasbredelAuthor Commented:
Here is the solution....

On GotFocus of the textbox call SetKeyboardNumeric()
On LostFocus of the textbox call SetKeyboardNormal()

        public void SetKeyboardNumeric()
            Process p = Process.GetCurrentProcess();
            if (p.MainWindowHandle != IntPtr.Zero)
                SHSetImeMode(p.MainWindowHandle, SHIME_MODE.SHIME_MODE_NUMBERS);
        public void SetKeyboardNormal()
            Process p = Process.GetCurrentProcess();
            if (p.MainWindowHandle != IntPtr.Zero)
                SHSetImeMode(p.MainWindowHandle, SHIME_MODE.SHIME_MODE_NONE);
        private enum SHIME_MODE
            SHIME_MODE_NONE = 0,
            SHIME_MODE_SPELL = 1,
            SHIME_MODE_SPELL_CAPS = 2,
            SHIME_MODE_AMBIGUOUS = 4,
            SHIME_MODE_NUMBERS = 7,
            SHIME_MODE_CUSTOM = 8
        private static extern int SHSetImeMode(IntPtr hWnd, SHIME_MODE nMode);

Open in new window

I tried the above code on a Treo750 device within an application running Windows Mobile 6 and had no success.  Do you know a working solution?
tarasbredelAuthor Commented:
It works for me on 2 different model (Asus and HP)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now