Microsoft KB Archive/155488

{|
 * width="100%"|

How To Stop IME for a Control
'Article ID: Q155488

Creation Date: 29-AUG-1996

Revision Date: 11-JAN-1997' The information in this article applies to:

Microsoft Win32 Software Development Kit for - Microsoft Windows NT version 3.51 - Microsoft Windows 95 version 4.0 SUMMARY

Some applications need to disable the IME (Input Method Editor) for an Edit control (or ListBox control, or ComboBox control), so that the user cannot enter double-byte characters into that control. This article describes how to stop IME for a control.

MORE INFORMATION

When the IME is activated by the user or activated programmatically on a double-byte system (such as Japanese Windows 95, or Japanese NT), a WM_IME_NOTIFY (IMN_OPENSTATUSWINDOW) message is sent to the control that currently has the focus. To stop the user from using the Input Method Editor, this particular control must be subclassed, and the WM_IME_NOTIFY message trapped. If the IME is being opened, then ImmSetOpenStatus is called to close the IME.

The following code shows how to stop IME for an Edit control:

Sample Code

... // subclass the Edit control to use a subclass procedure: // EditSubProc OldEditProc = SetWindowLong(gEditWnd, GWL_WNDPROC, EditSubProc); ...

// the Edit Control subclass procedure LRESULT CALLBACK EditSubProc(HWND hWnd,

UINT message, WPARAM wParam, LPARAM lParam) { HIMC himc;

switch (message) {   case WM_IME_NOTIFY: if (wParam == IMN_SETOPENSTATUS) {       himc = ImmGetContext(hWnd); // if the IME is open, close it. if (ImmGetOpenStatus(himc)) ImmSetOpenStatus(himc, FALSE); }     break;

default: CallWindowProc(OldEditProc, hWnd, message, wParam, lParam); } } To stop IME for a ComboBox control, the Edit control in the ComboBox must be subclassed.
 * }

-

 KBCategory: kbprg kbhowto

KBSubcategory: wintldev

Additional reference words: 3.10 4.00 kbdsd combo box list box

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''