Archive for April, 2009

Programmatically set Input Context features

Thursday, April 30th, 2009

In my last blog post I discussed how an end user could change word completion features at a system wide level. This blog post covers how a .NET Compact Framework developer can programatically change the behaviour on a textbox by textbox basis.

The Windows Mobile operating system provides a function called SHSetInputContext that enables a developer to configure the various properties of the input context associated with a given control.

By using a DllImport declaration we can gain access to this native function from our C# application as shown below:

using System.Runtime.InteropServices;
private enum SHIC_FEATURE : uint
  CLASS = 4
private static extern int SHSetInputContext(IntPtr hwnd,
  SHIC_FEATURE dwFeature,
  [MarshalAs(UnmanagedType.Bool)]ref bool lpValue);

Once declared it is as easy as passing a boolean true or false value to SHSetInputContext along with the name of the input context feature we want to configure.

For example to disable auto suggestion for a textbox called “textbox1″ we could use the following code snippet:

bool value = false;
  ref value);

Sample application

[Download - 10.6KB]

A sample application is available for download. It wraps up the calls to SHSetInputContext into a handy InputContext class that can be re-used within your own applications.

The sample application has a single textbox and a series of checkboxes. The checkboxes enable you to control the various input context features present within the Word Completion tab of the Input control panel applet for the textbox.

We’ll round out our discussion of Input Contexts by covering Input Classes within the next blog post. In the mean time see if you can determine what changes in behaviour occur when you select the various options within the Input Class combo box.
Screenshot of sample application demonstrating setting Input Context features

Windows Mobile Tip: Word Completion settings

Thursday, April 23rd, 2009

Screenshot showing location of Input control panel applet and the Word Completion tabAnother Windows Mobile feature that is commonly undiscovered are the word completion settings. You can find these within the “Input” control panel applet, found within the Personal tab of the Settings application.

Although the labeling and precise set of options available changes with Windows Mobile version you should be able to configure the following types of word completion features:

  • Suggest words when entering text: Should Windows Mobile suggest possible ways to complete the word currently being entered via a popup list.
  • Add a space after word: Should a space be automatically inserted if the user selects a word from the word completion list.
  • Enable auto correct: Should common typing mistakes such as typing “youre” when you meant “you’re” be corrected automatically when typing a space after the word.

Enabling the Auto Correct feature is more practical for English speakers than it is for other users of other languages. The rules and auto corrections are rather hardcoded and may interfere with phrases common in other languages. You may spend more time correcting the auto corrections than it spends correcting your mistakes!

Now for the bad news… your mileage may vary with this Windows Mobile Tip. Although the word completion feature is a standard part of the operating system there are a number of “moving parts” between the keyboard and the application which could affect text input behavior. Altering these settings on your particular device may or may not alter the word completion behavior of your device, as word completion may be implemented or controlled by another part of the software stack (for example a custom Software Input Panel developed by the device‚Äôs OEM).

Tomorrow we’ll discuss how a .NET Compact Framework developer can programmatically control these word completion features on a textbox by textbox case.

Visual Studio Tip: Import a *.reg file

Wednesday, April 22nd, 2009

Screenshot of Visual Studio IDE showing the Registry Import menu item

Here is a handy feature of Visual Studio which took me a while to discover when I started using the tool.

As part of packaging up an application it is common to store configuration settings within the registry. While using a Smart Device CAB project you can use the convenient Registry view to set up these values graphically.

The feature that I didn’t notice for a while is the fact that you can right click on the window to get an Import… menu item (as shown in the screenshot above). This enables you to import a group of settings from a *.reg file, which saves you manually entering them all via the IDE.

So how do you create a *.reg file? One way is to manually write one in a text editor. Another is to generate it via the Windows CE Remote Registry Editor utility. Once you have configured your device you can use this tool to export a specific sub-tree of the device’s registry as a *.reg file that you can then import directly into Visual Studio.

Screenshot of Windows CE Remote Registry Editor utility showing the Export Registry File menu option

DNUG Meeting: SQL Server 2008 New Features tour

Monday, April 20th, 2009
Photo of Rob Hawthorne
Date: Tuesday April 28th 2009
Time: Gather at 5:30 pm, starting at 6:00 pm
Location: Canterbury Innovation Incubator
Presenter: Rob Hawthorne

SQL Server 2008 delivers on Microsoft’s Data Platform vision by helping your organization manage any data, any place, any time.

This new release builds on the great platform laid with SQL Server 2005, enhancing it with great new capabilities such as native support for spatial data, database encryption and compression and enhanced manageability through Policy Based Management, Powershell and the Resource Governor as well as many new great enhancements for Analysis Services and Reporting Services.

Come join us for the Christchurch stop of this national tour, as we delve into the new features of SQL Server 2008 and the benefits they can bring to your organisation.