|
KAZさん、こんにちはぁ
遅れてごめんなさい。
>>引値の数が違いますが、私のサンプルの ImmGetConversionList の部分を、ImmGetCandidateList に置き換えればほぼ大丈夫です。
>>多分使えないとは思いますけど、必要ならサンプルでも作りますよ。
>ぜひぜひ、サンプルを作ってください、お願い致します。
下のほうにサンプルを付けときます。
ほとんど、ImmGetConversionListの時と同じです。
変換中の候補を取得するものなので、変換文字の指定はできません^^;
あとは、ImmSetCompositionString関数かなぁ^^;;
ではではぁ
'---- 8< ---- 8= ---- 8< ---- 8= ---- 8< ---- 8= ---- 8< ---- 8= ----
' IME関連API定義
Private Declare Function ImmGetDefaultIMEWnd Lib "imm32.dll" (ByVal hWnd As Long) As Long
Private Declare Function ImmGetContext Lib "imm32.dll" (ByVal hWnd As Long) As Long
Private Declare Function ImmReleaseContext Lib "imm32.dll" (ByVal hWnd As Long, ByVal himc As Long) As Long
Private Declare Function ImmGetCandidateList Lib "imm32.dll" Alias "ImmGetCandidateListA" (ByVal himc As Long, ByVal deIndex As Long, lpCandidateList As Any, ByVal dwBufLen As Long) As Long
Private Declare Sub MemCpy Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type CANDIDATELIST
dwSize As Long
dwStyle As Long
dwCount As Long
dwSelection As Long
dwPageStart As Long
dwPageSize As Long
dwOffset(1) As Long
End Type
Public Function GetCandidateList() As Variant
Dim hKl As Long, hIMEWnd As Long, himc As Long
Dim lngLength As Long, lngOffset As Long
Dim abytBuffer() As Byte
Dim udtCandList As CANDIDATELIST
Dim lngPos As Long
Dim strConv As String
Dim lngCount As Long
Dim astrFuncResult() As String
lngCount = 0
'' IMEクラスの既定ウィンドウハンドルの取得
hIMEWnd = ImmGetDefaultIMEWnd(0&)
If hIMEWnd <> 0& Then
'' 入力コンテキスト作成
himc = ImmGetContext(hIMEWnd)
If himc <> 0& Then
'' 変換結果に必要なバッファサイズの取得
lngLength = ImmGetCandidateList(himc, 0&, ByVal 0&, 0&)
If lngLength > 0 Then
'' 変換結果取得
ReDim abytBuffer(lngLength - 1)
If ImmGetCandidateList(himc, 0&, abytBuffer(LBound(abytBuffer())), lngLength) <> 0& Then
'' バッファを構造体へコピー
MemCpy udtCandList, abytBuffer(LBound(abytBuffer())), LenB(udtCandList)
lngOffset = udtCandList.dwOffset(0)
If lngLength - lngOffset > 0 Then
'' 変換結果を文字列に変換
strConv = String(lngLength - lngOffset, vbNullChar)
MemCpy ByVal strConv, abytBuffer(LBound(abytBuffer()) + lngOffset), Len(strConv)
'' 変換結果分割
Do Until (Left$(strConv, 1) = vbNullChar) Or (Len(strConv) = 0)
For lngPos = 1 To Len(strConv)
If Mid$(strConv, lngPos, 1) = vbNullChar Then Exit For
Next
ReDim Preserve astrFuncResult(lngCount)
astrFuncResult(lngCount) = Left$(strConv, lngPos - 1)
strConv = Mid$(strConv, lngPos + 1)
lngCount = lngCount + 1
Loop
End If
End If
End If
'' 入力コンテキストの開放
Call ImmReleaseContext(hIMEWnd, himc)
End If
End If
GetCandidateList = IIf(lngCount > 0, astrFuncResult, Empty)
End Function
|
|