InputBox での漢字変換の設定 Hit Counter

対象バージョン :  97, 2000, 2002, 2003
最終更新日 : 2005/04/25 (オリジナル作成日:1998/11/01)


概 要 

InputBox 関数では、入力の際の漢字変換の設定が行えません。

InputBox 関数の前後で、Windows API を用いて IME の操作を行う方法です。

 

解 説

宣言

Declare Function ImmGetContext Lib "imm32.dll" (ByVal hwnd As Long) As Long
Declare Function ImmSetOpenStatus Lib "imm32.dll" _
    (ByVal himc As Long, ByVal b As Long) As Long
Declare Function ImmGetConversionStatus Lib "imm32.dll" _
    (ByVal himc As Long, lpdw As Long, lpdw2 As Long) As Long
Declare Function ImmSetConversionStatus Lib "imm32.dll" _
    (ByVal himc As Long, ByVal dw1 As Long, ByVal dw2 As Long) As Long
Declare Function ImmReleaseContext Lib "imm32.dll" _
    (ByVal hwnd As Long, ByVal himc As Long) As Long

Public Const IME_CMODE_NATIVE = &H1
Public Const IME_CMODE_KATAKANA = &H2
Public Const IME_CMODE_FULLSHAPE = &H8
Public Const IME_CMODE_ROMAN = &H10
Public Const IME_CMODE_ALPHANUMERIC = &H0

プロシージャ

Dim result As Long
Dim reply
Dim lpdw As Long
Dim lpdw2 As Long
Dim himc As Long

himc = ImmGetContext(hWndAccessApp)
result = ImmSetOpenStatus(himc, -1&)
result = ImmGetConversionStatus(himc, lpdw, lpdw2)
lpdw = IME_CMODE_NATIVE + IME_CMODE_FULLSHAPE + IME_CMODE_ROMAN
result = ImmSetConversionStatus(himc, lpdw, lpdw2)
reply = InputBox("値を入力してください")
result = ImmSetOpenStatus(himc, 0&)
result = ImmReleaseContext(hwndAccessApp, himc)

補 足


目次へ戻る