1 | #include "stdafx.h" |
---|
2 | |
---|
3 | #include "common.h" |
---|
4 | |
---|
5 | extern HFONT hFont_TextEdit,hFont_HyperLink_TextEdit; |
---|
6 | extern int font_width,font_height; |
---|
7 | |
---|
8 | void TextEditEvent_IME_StartComposition(HWND hwnd){ |
---|
9 | int WndNum; |
---|
10 | WndNum=GetWndNum(GetParent(hwnd)); |
---|
11 | |
---|
12 | int iControlTabSpace; |
---|
13 | iControlTabSpace=MdiInfo[WndNum]->pMdiTextEdit->iWidth_ControlTabSpace; |
---|
14 | |
---|
15 | HIMC hIMC; |
---|
16 | hIMC=ImmGetContext(hwnd); |
---|
17 | |
---|
18 | //コンポジションをセット |
---|
19 | POINT pos; |
---|
20 | COMPOSITIONFORM CompForm; |
---|
21 | CompForm.dwStyle=CFS_POINT; |
---|
22 | pos=MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos; |
---|
23 | GetScrollBaseCaretPos(MdiInfo[WndNum],(int *)&pos.x,(int *)&pos.y); |
---|
24 | CompForm.ptCurrentPos.x=pos.x*font_width+iControlTabSpace; |
---|
25 | CompForm.ptCurrentPos.y=pos.y*font_height; |
---|
26 | ImmSetCompositionWindow(hIMC, &CompForm); |
---|
27 | |
---|
28 | //フォントをセット |
---|
29 | ImmSetCompositionFont(hIMC,&pobj_nv->lf); |
---|
30 | |
---|
31 | ImmReleaseContext(hwnd,hIMC); |
---|
32 | } |
---|
33 | |
---|
34 | BOOL TextEditEvent_IME_Composition(HWND hwnd,LPARAM lParam){ |
---|
35 | if(lParam&GCS_RESULTSTR){ |
---|
36 | int WndNum; |
---|
37 | WndNum=GetWndNum(GetParent(hwnd)); |
---|
38 | |
---|
39 | int iControlTabSpace; |
---|
40 | iControlTabSpace=MdiInfo[WndNum]->pMdiTextEdit->iWidth_ControlTabSpace; |
---|
41 | |
---|
42 | //////////////////// |
---|
43 | // 確定文字列を取得 |
---|
44 | //////////////////// |
---|
45 | |
---|
46 | //コンテキストを取得 |
---|
47 | HIMC hIMC; |
---|
48 | hIMC=ImmGetContext(hwnd); |
---|
49 | |
---|
50 | int i; |
---|
51 | char temporary[4096]; |
---|
52 | i=ImmGetCompositionString(hIMC, GCS_RESULTSTR, temporary,4096); |
---|
53 | if(i==0) return 0; |
---|
54 | temporary[i]=0; |
---|
55 | |
---|
56 | //バッファをリプレイス |
---|
57 | TextEdit_ReplaceUpdateUndoData(WndNum,temporary,0,1); |
---|
58 | UpdateWindow(hwnd); |
---|
59 | |
---|
60 | //コンポジションをセット(立て続けにIME入力が行われる場合を考慮) |
---|
61 | POINT pos; |
---|
62 | COMPOSITIONFORM CompForm; |
---|
63 | CompForm.dwStyle=CFS_POINT; |
---|
64 | pos=MdiInfo[WndNum]->pMdiTextEdit->StartCaretPos; |
---|
65 | GetScrollBaseCaretPos(MdiInfo[WndNum],(int *)&pos.x,(int *)&pos.y); |
---|
66 | CompForm.ptCurrentPos.x=pos.x*font_width+iControlTabSpace; |
---|
67 | CompForm.ptCurrentPos.y=pos.y*font_height; |
---|
68 | ImmSetCompositionWindow(hIMC, &CompForm); |
---|
69 | |
---|
70 | //コンテキストを解放 |
---|
71 | ImmReleaseContext(hwnd,hIMC); |
---|
72 | } |
---|
73 | |
---|
74 | return 1; |
---|
75 | } |
---|