Home > Software engineering >  How to identify text box input method changes
How to identify text box input method changes

Time:09-22

Want to use VB to make up a program, in a text box, the user first use sogou pinyin input method input text, and then with wangma wubi continue to enter text, is there a way to identify this text box input method during the state change? Please expert guidance

CodePudding user response:

There should be a way, specific don't know,,

Just baidu, you under reference:
http://www.itnose.net/detail/150092.html
http://blog.csdn.net/liuliu0103/article/details/6294564

Won't have time to try, you study

CodePudding user response:

A imemode properties,

CodePudding user response:

Imemode attributes only to limit the text frame's status in both English and Chinese, doesn't recognize text box in the current state of what Chinese input method
Please moderators can provide code to study in detail, thank you!

CodePudding user response:

GetKeyboardLayout
ImmGetDescription
?

CodePudding user response:

reference 4 floor zhao4zhong1 response:
GetKeyboardLayout
ImmGetDescription
?


Consult the master can give specific code?

CodePudding user response:

reference 5 floor sinat_37422271 reply:
Quote: refer to 4th floor zhao4zhong1 response:

GetKeyboardLayout
ImmGetDescription
?


Consult the master can give specific code?

Baidu search the two key words,

CodePudding user response:

Chinese input method, it is with the aid of western keyboard and specific code generation Chinese character encoding method, the Chinese input method as "high-jack", it intercepted keyboard message is passed to the system, converts it to the Chinese character encoding, use it as a message to your text box control,

Therefore, whether from the text box to receive the message, or the text frame's own condition, won't be known which is inserted in the middle of a "hero",

Information about input method, can only be achieved through the operating system,

First of all, with the following API function to obtain a handle (dwLayout=0) :
Public Declare Function GetKeyboardLayout Lib "user32" Alias "GetKeyboardLayout" (ByVal dwLayout As Long) As Long

Then, put the handle into the following function of HKL parameters to obtain input method name, LPSZ cache is the string uBufLen is length, can be set to 255,
Public Declare Function ImmGetDescription Lib "imm32. DLL" Alias "ImmGetDescriptionA" (ByVal HKL As Long, ByVal LPSZ As String, ByVal uBufLen As Long) As Long

But not all input method can get a text name, at this point, use a look-up table method to know the current input method is obtained by HKL handle,
E0010804 whole put together im version 5.0
E0040804 smart ABC input method version 5.0
E0050804 location input method 5.0
E0100804 wangma wubi input method 86 edition
E0110804 wangma wubi input method 98 edition
E0200804 purple light pinyin input method 3.0
08040804 Microsoft pinyin 2003
04040404 [Taiwan] Microsoft phonetic input method
08090809 English









CodePudding user response:

 Option Explicit 
Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long

Private Declare Function ImmGetDescription Lib "imm32. DLL" Alias "ImmGetDescriptionA" (ByVal HKL As Long, ByVal LPSZ As String, ByVal uBufLen As Long) As Long

Dim list1 As the Variant, list2 As the Variant

Private Sub Command1_Click ()
Dim ret As Long, HKL As Long, As Long I
Dim strTmp As String

HKL=GetKeyboardLayout (0)
StrTmp=Space (255)

Ret=ImmGetDescription (HKL, strTmp, 255)

StrTmp=Trim (strTmp)
If strTmp & gt; "" Then
Text1=strTmp
The Else
For I=0 To UBound (list1)
If HKL=list1 (I) Then strTmp=list2 (I)
Next I

If strTmp & gt; "" Then
Text1=strTmp
The Else
Text1=Right (" 00000000 "& amp; Hex (HKL), 8)
End the If
End the If
End Sub

Private Sub Form_Load ()
List1=Array (& amp; H8040804, & amp; H4040404, & amp; H8090809, & amp; H4090409)
List2=Array (" 2003 Microsoft pinyin input method ", "Microsoft phonetic input method [Taiwan]", "English [British]", "English [us]")
End Sub
  • Related