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