#include "stdafx.h" #include "common.h" extern HFONT hFont_TextEdit,hFont_HyperLink_TextEdit; extern int font_width,font_height; void TextEditEvent_IME_StartComposition(HWND hwnd){ int WndNum; WndNum=GetWndNum(GetParent(hwnd)); int iControlTabSpace; iControlTabSpace=MdiInfo[WndNum]->pMdiTextEdit->iWidth_ControlTabSpace; HIMC hIMC; hIMC=ImmGetContext(hwnd); //コンポジションをセット POINT pos; COMPOSITIONFORM CompForm; CompForm.dwStyle=CFS_POINT; pos=MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos; GetScrollBaseCaretPos(MdiInfo[WndNum],(int *)&pos.x,(int *)&pos.y); CompForm.ptCurrentPos.x=pos.x*font_width+iControlTabSpace; CompForm.ptCurrentPos.y=pos.y*font_height; ImmSetCompositionWindow(hIMC, &CompForm); //フォントをセット ImmSetCompositionFont(hIMC,&pobj_nv->lf); ImmReleaseContext(hwnd,hIMC); } BOOL TextEditEvent_IME_Composition(HWND hwnd,LPARAM lParam){ if(lParam&GCS_RESULTSTR){ int WndNum; WndNum=GetWndNum(GetParent(hwnd)); int iControlTabSpace; iControlTabSpace=MdiInfo[WndNum]->pMdiTextEdit->iWidth_ControlTabSpace; //////////////////// // 確定文字列を取得 //////////////////// //コンテキストを取得 HIMC hIMC; hIMC=ImmGetContext(hwnd); int i; char temporary[4096]; i=ImmGetCompositionString(hIMC, GCS_RESULTSTR, temporary,4096); if(i==0) return 0; temporary[i]=0; //バッファをリプレイス TextEdit_ReplaceUpdateUndoData(WndNum,temporary,0,1); UpdateWindow(hwnd); //コンポジションをセット(立て続けにIME入力が行われる場合を考慮) POINT pos; COMPOSITIONFORM CompForm; CompForm.dwStyle=CFS_POINT; pos=MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos; GetScrollBaseCaretPos(MdiInfo[WndNum],(int *)&pos.x,(int *)&pos.y); CompForm.ptCurrentPos.x=pos.x*font_width+iControlTabSpace; CompForm.ptCurrentPos.y=pos.y*font_height; ImmSetCompositionWindow(hIMC, &CompForm); //コンテキストを解放 ImmReleaseContext(hwnd,hIMC); } return 1; }