// ImmSetCompositionWindowとImmSetCompositionFontのラッパー protected void SetImeContext(bool setFont) { IntPtr hIMC = ImmGetContext(this.Handle); if (hIMC == IntPtr.Zero) { return; } try { // ウィンドウセット COMPOSITIONFORM form = new COMPOSITIONFORM(); form.dwStyle = CFS_POINT; form.ptCurrentPos.x = 55; // MEMO:X位置設定 form.ptCurrentPos.y = 55; // MEMO:Y位置設定 ImmSetCompositionWindow(hIMC, ref form); // if (withFont) { // なんかラッパかまして変換しないとうまくいかない // object logFontWrap = new LOGFONT(); // this.Font.ToLogFont(logFontWrap); // LOGFONT logFont = (GDIMagician.LOGFONT)logFontWrap; // byte[] by = Encoding.Default.GetBytes(this.Font.Name); // MEMO:英語環境とかの挙動怪しいかも? // for (int i = 0; i < logFont.lfFaceName.Length; i++) { // logFont.lfFaceName[i] = (i >= by.Length) ? (byte)0 : by[i]; // } // ImmSetCompositionFont(hIMC, ref logFont); // } */ } finally { ImmReleaseContext(this.Handle, hIMC); } }
protected override void UpdateImeComposition(int aLParam) { if (FInputHelper.EnableEx && ((aLParam & Imm.GCS_COMPSTR) != 0)) { string vS = GetCompositionStr(Imm.GCS_COMPSTR); FInputHelper.SetCompositionString(vS); if (FInputHelper.ChangeSize) { COMPOSITIONFORM vCF = new COMPOSITIONFORM(); if (Imm.ImmGetCompositionWindow(this.hImc, ref vCF)) { if (FInputHelper.ResetImeCompRect(ref vCF.ptCurrentPos)) { Imm.ImmSetCompositionWindow(this.hImc, ref vCF); } } } } if ((aLParam & Imm.GCS_RESULTSTR) != 0) { string vS = GetCompositionStr(Imm.GCS_RESULTSTR); if (vS != "") { if (DoProcessIMECandi(vS)) { InsertText(vS); } } } }
private void SetIMEWindowLocation(int x, int y) { if (pIMEWnd == IntPtr.Zero) { return; } POINT p = new POINT(); p.x = x; p.y = y; COMPOSITIONFORM lParam = new COMPOSITIONFORM(); lParam.dwStyle = CFS_POINT; lParam.ptCurrentPos = p; lParam.rcArea = new RECT(); try { SendMessage( pIMEWnd, WM_IME_CONTROL, new IntPtr(IMC_SETCOMPOSITIONWINDOW), lParam ); } catch (AccessViolationException ex) { MessageBox.Show("调用 IME: " + ex.Message); } }
public void SetIMEWindowLocation(int x, int y) { if (disableIME || hIMEWnd == IntPtr.Zero) { return; } POINT p = new POINT(); p.x = x; p.y = y; COMPOSITIONFORM lParam = new COMPOSITIONFORM(); lParam.dwStyle = CFS_POINT; lParam.ptCurrentPos = p; lParam.rcArea = new RECT(); try { SendMessage( hIMEWnd, WM_IME_CONTROL, new IntPtr(IMC_SETCOMPOSITIONWINDOW), lParam ); } catch (AccessViolationException ex) { Handle(ex); } }
public static void GetImeWindowPos(IntPtr window) { var imContext = ImmGetContext(window); var compForm = new COMPOSITIONFORM(); ImmGetCompositionWindow(imContext, out compForm); Console.WriteLine(compForm.area.left - compForm.area.right); ImmReleaseContext(window, imContext); }
public void SetImeWindowsPos(int x, int y) { COMPOSITIONFORM Composition = new COMPOSITIONFORM(); Composition.dwStyle = CFS_POINT; Composition.ptCurrentPos.x = x; Composition.ptCurrentPos.y = y; ImmSetCompositionWindow(m_hImc, ref Composition); }
/// <summary> /// 设置输入法位置 /// </summary> /// <param name="x"></param> /// <param name="y"></param> public void setImePosition(int x, int y) { COMPOSITIONFORM cf = new COMPOSITIONFORM(); cf.dwStyle = 2; cf.ptCurrentPos.x = x; cf.ptCurrentPos.y = y; bool setcom = ImmSetCompositionWindow(hIMC, ref cf); //ImmReleaseContext(hIMC, handle); }
public void UpdateCompositionForContent() { int imc = ImmGetContext(this.Handle); COMPOSITIONFORM cf = new COMPOSITIONFORM(); cf.dwStyle = CFS_POINT; cf.ptCurrentPos = new Point(); cf.ptCurrentPos.x = this.ParentControl.CaretPosition.X - this.ParentControl.ViewPosition.X; cf.ptCurrentPos.y = this.ParentControl.CaretPosition.Y - this.ParentControl.ViewPosition.Y; int res = ImmSetCompositionWindow(imc, ref cf); }
/// <summary>Sets location of the IME composition window (pre-edit window) </summary> public static void SetImeWindowPos(IntPtr imContext, IntPtr window, Point screenPos) { const int CFS_POINT = 0x0002; var compForm = new COMPOSITIONFORM { style = CFS_POINT, currentPos = new POINT(screenPos), area = new RECT() }; ImmSetCompositionWindow(imContext, ref compForm); }
public void ImeStartcomposition(Message m, int x, int y) { int hIMC = ImmGetContext(this.control.Handle); COMPOSITIONFORM cf = new COMPOSITIONFORM(); cf.dwStyle = CFS_POINT; cf.ptCurrentPos = new Point(); cf.ptCurrentPos.x = x; cf.ptCurrentPos.y = y; int res = ImmSetCompositionWindow(hIMC, ref cf); ImmReleaseContext(this.control.Handle, hIMC); }
/// <summary>Sets location of the IME composition window (pre-edit window) </summary> public static void SetImeWindowPos(IntPtr imContext, IntPtr window, Point screenPos) { const int CFS_POINT = 0x0002; COMPOSITIONFORM compForm = new COMPOSITIONFORM(); unsafe { compForm.style = CFS_POINT; compForm.currentPos = new POINT(screenPos); compForm.area = new RECT(); ImmSetCompositionWindow(imContext, &compForm); } }
public void SetIMEWindowLocation(int x, int y) { POINT p = new POINT(); p.x = x; p.y = y; COMPOSITIONFORM lParam = new COMPOSITIONFORM(); lParam.dwStyle = CFS_POINT; lParam.ptCurrentPos = p; lParam.rcArea = new RECT(); int i = SendMessage( hIMEWnd, WM_IME_CONTROL, IMC_SETCOMPOSITIONWINDOW, lParam ); }
void SetImeCompstionWindowPos(IntPtr window, int x, int y) { IntPtr imContext; imContext = ImmGetContext(window); COMPOSITIONFORM compForm = new COMPOSITIONFORM(); unsafe { compForm.style = CFS_POINT; compForm.currentPos = new POINT(x, y); compForm.area = new RECT(); ImmSetCompositionWindow(imContext, &compForm); } ImmReleaseContext(window, imContext); }
public void SetIMEWindowLocation(int x, int y) { POINT p = new POINT(); p.x = x; p.y = y; COMPOSITIONFORM lParam = new COMPOSITIONFORM(); lParam.dwStyle = CFS_POINT; lParam.ptCurrentPos = p; lParam.rcArea = new RECT(); SendMessage( hIMEWnd, WM_IME_CONTROL, IMC_SETCOMPOSITIONWINDOW, lParam ); }
public void SetImeContext(int x, int y) { IntPtr hIMC = ImmGetContext(this.Handle); if (hIMC == IntPtr.Zero) { return; } try { // ウィンドウセット COMPOSITIONFORM form = new COMPOSITIONFORM(); form.dwStyle = CFS_POINT; form.ptCurrentPos.x = x; // MEMO:X位置設定 form.ptCurrentPos.y = y; // MEMO:Y位置設定 ImmSetCompositionWindow(hIMC, ref form); } finally { // ImmReleaseContext(this.Handle, hIMC); } }
/// <summary> /// </summary> public static Boolean SetCompositionWindowPosition(IntPtr immContext, Point pt, Visual relativeTo) { if (immContext == IntPtr.Zero) { throw new ArgumentNullException("immContext"); } if (relativeTo == null) { throw new ArgumentNullException("relativeTo"); } Visual rootVisual = GetRootVisual(relativeTo); if (rootVisual == null) { return(false); } Point point = relativeTo.TransformToAncestor(rootVisual).Transform(pt); HwndSource hwndSource = GetHwndSource(rootVisual); if (hwndSource != null) { point = hwndSource.CompositionTarget.TransformToDevice.Transform(point); } COMPOSITIONFORM structure = new COMPOSITIONFORM(); structure.dwStyle = 2; structure.ptCurrentPos = new POINT((Int32)point.X, (Int32)point.Y); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, true); Boolean flag = Imm32.ImmSetCompositionWindow(immContext, ptr); Marshal.FreeHGlobal(ptr); return(flag); }
protected override void UpdateImePosition() { COMPOSITIONFORM vCF = new COMPOSITIONFORM(); vCF.ptCurrentPos.X = Caret.X; vCF.ptCurrentPos.Y = Caret.Y + Caret.Height + 4; if (FInputHelper.EnableEx) { FInputHelper.ResetImeCompRect(ref vCF.ptCurrentPos); } vCF.dwStyle = 0x0020; Rectangle vr = this.ClientRectangle; vCF.rcArea = new RECT(vr.Left, vr.Top, vr.Right, vr.Bottom); Imm.ImmSetCompositionWindow(this.hImc, ref vCF); if (FInputHelper.EnableEx) { FInputHelper.CompWndMove(this.Handle, Caret.X, Caret.Y + Caret.Height); } }
private static extern int SendMessage(IntPtr hWnd, int msg, int wParam, COMPOSITIONFORM lParam);
public static extern int ImmGetCompositionWindow(IntPtr himc, ref COMPOSITIONFORM lpCompositionForm);
public static extern IntPtr SendMessage(int hwnd, int wMsg, int wParam, COMPOSITIONFORM lParam);
public static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref COMPOSITIONFORM form);
static extern Int32 ImmGetCompositionWindow(IntPtr imContext, out COMPOSITIONFORM compForm);
public void SetIMEWindowLocation(int x, int y) { if (disableIME || hIMEWnd == IntPtr.Zero) return; POINT p = new POINT(); p.x = x; p.y = y; COMPOSITIONFORM lParam = new COMPOSITIONFORM(); lParam.dwStyle = CFS_POINT; lParam.ptCurrentPos = p; lParam.rcArea = new RECT(); try { SendMessage(hIMEWnd, WM_IME_CONTROL, new IntPtr(IMC_SETCOMPOSITIONWINDOW), lParam); } catch (AccessViolationException ex) { Handle(ex); } }
public static extern int ImmSetCompositionWindow(int hIMC, ref COMPOSITIONFORM lpCompositionForm);
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, COMPOSITIONFORM lParam);
/// <summary> /// ���¹����ʾ��λ�ú�״̬�� /// </summary> private void UpdateCaret() { if (caretVisible) DestroyCaret(); caretVisible = Focused && selLength <= 0; if (!caretVisible) return; Point vPoint = CoordinateFromPosistion( selStart + (caretFirst ? 0 : selLength)); CreateCaret(Handle, IntPtr.Zero, 2, itemHeight); ShowCaret(Handle); bool b = endCaret && vPoint.X == 0 && vPoint.Y > 0; if (b) { vPoint.X = 16; vPoint.Y--; } vPoint = PointFromColRow(colType, vPoint.X, vPoint.Y); vPoint.X += 1; if (colType == HitTestType.Hex && modifyHex != '\x0') vPoint.X += itemWidth * 2; if (b && colType == HitTestType.Hex) vPoint.X -= itemWidth; SetCaretPos(vPoint.X, vPoint.Y); IntPtr vImc = ImmGetContext(Handle); COMPOSITIONFORM vCompForm = new COMPOSITIONFORM(); vCompForm.dwStyle = CFS_POINT; vCompForm.ptCurrentPos = vPoint; ImmSetCompositionWindow(vImc, ref vCompForm); ImmReleaseContext(Handle, vImc); }
static extern void ImmSetCompositionWindow(IntPtr hIMC, ref COMPOSITIONFORM lpCompForm);
public static extern bool ImmSetCompositionWindow(IntPtr hWnd, COMPOSITIONFORM lpCompForm);
public static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref COMPOSITIONFORM lpCompForm);
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (Graphics g = this.CreateGraphics()) { g.DrawImage(sDoc.DrawBuffer, 0, 0); } Point p = sDoc.CursorLocation(); // 更新光标位置 SetCaretPos((int)(sDoc.MarginHorizontal() + p.X), p.Y); // 更新输入法悬浮窗口位置 COMPOSITIONFORM cf = new COMPOSITIONFORM(); cf.dwStyle = 2; cf.ptCurrentPos.x = (int)(sDoc.MarginHorizontal() + p.X + 10); cf.ptCurrentPos.y = (int)(sDoc.MarginHorizontal() + p.Y + 10); ImmSetCompositionWindow(this.hIMC, ref cf); }