Solved

Change hardware keyboard layout from CF.net

Posted on 2008-06-26
5
2,151 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

777 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