IME Sample: Demonstrates How to Control IME Mode and Implement IME Level 3
The IME sample uses CIMEEdit, a subclass of CEdit, to create an edit control. CIMEEdit handles all input characters, and it composes DBCS strings. The sample has the following features:
It shows how to control IME mode using C/C++. You can set the initial IME mode of CIMEEdit as to input language, shape, and so on. If you want your edit control initially set to get Korean characters, you can add code as in this sample. Also, if you want only English, you can disable IME.
It also shows how to implement IME level 3 in your source code. IME level 3 is more convenient and powerful for East Asian users. You can create a custom control or window that supports IME level 3 using this sample.
This sample determines the font and code page used for Ansi-Unicode conversion by the keyboard layout so that you can try four different IMEs for all East Asian languages without changing either font or code page. This is a feature of Windows 2000 and is not a requirement for support of IME level 3.
The function GetCombinedCharLength supports only surrogate characters in this sample. If you need to support combined characters, add your code to the method.
To use IME functions, your program must include IMM.H and link with IMM32.LIB.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
Building and Running the Sample
To build and run this sample
Open the solution IME.sln.
From the Build menu, click Build.
From the Debug menu, click Start Without Debugging.
Run the sample and try out the following features.
Control IME Mode
You can change IME mode using check boxes. If you change options using check boxes, the status of the IME window will be changed.
You can change IME mode using the IME window. If you change options using the IME window, check boxes in the sample will be changed.
You can enable or disable IME.
Implement IME Level 3
If you input double-byte characters, you can see how to composite strings.
If you have the proper font on Windows 2000, you can see surrogate characters.
Classes and Keywords
This sample demonstrates the following classes:
This sample demonstrates the following keywords:
CBitmap::OnPaint; CEdit::OnChar; CEdit::OnSetFocus; CEdit::OnKillFocus; CEdit::OnKeyDown; CEdit::WindowProc; ImmGetContext; ImmReleaseContext; ImmGetConversionStatus; ImmSetConversionStatus; ImmGetOpenStatus; ImmSetOpenStatus; ImmAssociateContext; ImmNotifyIME; ImmGetCompositionString; ImmGetProperty; ImmSetCandidateWIndow; ImmSetCompositionWIndow