Solved

Change hardware keyboard layout from CF.net

Posted on 2008-06-26
5
2,163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

623 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