Solved

Change hardware keyboard layout from CF.net

Posted on 2008-06-26
5
2,154 Views
Last Modified: 2013-12-27
Hi

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?

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

Thank you!
0
Comment
Question by:tarasbredel
  • 3
5 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 21882772
0
 

Author Comment

by:tarasbredel
ID: 21882886
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.

//Taras
0
 

Accepted Solution

by:
tarasbredel earned 0 total points
ID: 21924170
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_SPELL_CAPS_LOCK = 3,
            SHIME_MODE_AMBIGUOUS = 4,
            SHIME_MODE_AMBIGUOUS_CAPS = 5,
            SHIME_MODE_AMBIGUOUS_CAPS_LOCK = 6,
            SHIME_MODE_NUMBERS = 7,
            SHIME_MODE_CUSTOM = 8
        }
 
        [DllImport("aygshell.dll")]
        private static extern int SHSetImeMode(IntPtr hWnd, SHIME_MODE nMode);

Open in new window

0
 

Expert Comment

by:pentium10
ID: 22168280
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?
0
 

Author Comment

by:tarasbredel
ID: 22257613
It works for me on 2 different model (Asus and HP)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question