|
本帖最后由 q273814 于 2014-12-4 08:42 编辑
用DX自绘Edit控件往往没有真是的EDIT窗口存在
计算当前光标的位置
用API ImmSetCompositionWindow指定IME 窗口到当前光标位置
在WM_KEYDOWN消息中处理
- int nSelStart = 0, nSelEnd = 0;
- this->GetSel( nSelStart, nSelEnd );
- CPoint pntCursor = this->PosFromChar( nSelEnd );
- if ( pntCursor.x == -1)
- {
- nSelEnd -=1;
- if ( nSelEnd < 0 )
- {
- nSelEnd = 0;
- }
- pntCursor = this->PosFromChar( nSelEnd );
- }
- HIMC hImc = ImmGetContext(m_hWnd);
- COMPOSITIONFORM form;
- form.dwStyle = CFS_RECT;
- form.ptCurrentPos = CPoint(pntCursor.x,0);
- form.rcArea = CRect(pntCursor.x,0,pntCursor.x+300,100);
- ImmSetCompositionWindow(hImc,&form);
复制代码 |

|