|
▼kobasan さん:
Excelで動くのが出来ました。
シート上にフォームのボタンを作って、IMETestを割り当てて実行してみて下さい。
Option Explicit
Public Declare Function ImmGetContext Lib "imm32.dll" _
(ByVal hWnd As Long) As Long
Public Declare Function ImmReleaseContext Lib "imm32.dll" _
(ByVal hWnd As Long, _
ByVal hIMC As Long) As Long
Public Declare Function ImmSetConversionStatus Lib "imm32.dll" _
(ByVal hIMC As Long, _
ByVal dw1 As Long, _
ByVal dw2 As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function ImmSetOpenStatus Lib "imm32.dll" _
(ByVal hIMC As Long, ByVal b As Long) As Long
Public Declare Function ImmGetOpenStatus Lib "imm32" _
(ByVal hIMC As Long) As Long
Public Const IME_CMODE_SOFTKBD = &H80 'ソフトキーボードモード
Public Const IME_SMODE_AUTOMATIC = &H4
'IMEモード定数
Public Const IME_CMODE_OFF = &H0&
Public Const IME_CMODE_NATIVE = &H1&
Public Const XLCLASS As String = "XLMAIN"
Sub IMETest()
Dim IMC As Long
Dim lngResult As Long
Dim lhWnd As Long
'ここはExcelのHWNDを取得。
lhWnd = FindWindow(XLCLASS, CStr(Application.Caption))
Debug.Print lhWnd
IMC = ImmGetContext(lhWnd)
' IMEがOffならOnにする。
If ImmGetOpenStatus(IMC) = IME_CMODE_OFF Then
Call ImmSetOpenStatus(IMC, IME_CMODE_NATIVE)
End If
lngResult = ImmSetConversionStatus(IMC, IME_CMODE_SOFTKBD, IME_SMODE_AUTOMATIC)
ImmReleaseContext lhWnd, IMC
End Sub
多分大丈夫と思いますが。。。。、実は先ほどUPしたものを再度確認していたら
動かなかったので、削除して、訂正したものです。
|
|