Next, let's talk about switching input methods and IMM/ime

Source: Internet
Author: User

This article aims to make a patch for the omissions in the previous article, and then discuss the content related to the input method in detail.ProgramIt is inevitable that you will encounter typing requirements. When you mention typing, you will inevitably encounter input methods.

 

The first is a supplement to the previous article. If you copy the previous article directlyCodeThe execution may find that there is no imaginary mouse, and the input method has changed. Why. Because I missed a step, that is, resetting the input method status.

Before calling immsetconvertionstatus, you must set imemode = imemode. on for the control to switch the input method.

So what is the role of imemode? As we all know, the textbox and other controls in winform (including maskedtextbox) contain an imemode attribute, this attribute actually calls the immsetconvertionstatus method at the underlying layer to set the Input Method to the specified enumerated values:

Figure 1

Figure 2

According to reflector's results, we found that this enumeration was refined.

   Static  Imemodeconversion () {japanesetable  =    New  Imemode [] {imemode. inherit, imemode. disable, imemode. off, imemode. off, imemode. hiragana, imemode. hiragana, imemode. katakana, imemode. katakanahalf, imemode. alphafull, imemode. alpha}; koreantable  =     New  Imemode [] {imemode. inherit, imemode. disable, imemode. alpha, imemode. alpha, imemode. hangulfull, imemode. hangul, imemode. hangulfull, imemode. hangul, imemode. alphafull, imemode. alpha}; chinesetable  =     New Imemode [] {imemode. inherit, imemode. disable, imemode. off, imemode. close, imemode. on, imemode. onhalf, imemode. on, imemode. onhalf, imemode. off, imemode. off}; unsupportedtable  =     New  Imemode [  0  ];} 

Therefore, if you only need to set the full-width half-width of the input method or change the katakana of the Japanese input method, you only need to call the imemode attribute of textbox or similar controls. However, according to the Code obtained by reflector, I found that when I set imemode to call immsetconvertionstatus, the sentence value is always 0, that is to say, if the Japanese or Chinese group sentence feature to be switched is to, the imemode attribute cannot be used, but the WIN32API call method described above is used.

Based on the previous discussions, we can find out the relationship between IMM and IME. Imm is the text service of the operating system, which is available only for windows in the East Asian version, and IME is the Implementation Program of the input method, IME programs, such as Microsoft pinyin, smart ABC, and five are used. When IME is registered to IMM, Imm determines the ime program currently in use, and users cannot directly deal with ime, instead, you can only use the API interfaces provided by IMM, such as the immsetconvertionstatus we used earlier. Typical proxy Mode Application

Of course, the API functions provided by Imm are the interfaces between the ime program and IMM. If we want to implement our own input method, we only need to use these interfaces.

Appendix 1:

The meaning of the mode and setence values, defined by bit

| 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 |

| _ 98 (me) reserved _ | _ Chinese Punctuation _ | _ custom characters _ | _ not converted _ | _ keypad _ | _ Han (Chinese characters) _ | _ inner code _ | _ _ | _ fullwidth _ | _ katakana _ | _ local language _ |

| 1/0 | 1/0 | 1/0 | 1/0 | 1/0 | 1/0 |

| _ Key-by-key prompt _ | _ word Lenovo _ | _ automatic mode _ | _ single-word mode _ | _ multiple clauses _ | _ No group sentence _ |

In the table in the previous article, the mode Value of katakana half-width is 19, and the hexadecimal value is 10011.

Inner code | halfwidth | katakana | Local Language

Exactly match.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.