Solved

Change hardware keyboard layout from CF.net

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

Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now