public static bool SetCompositionWindow(HwndSource source, IntPtr hIMC, TextArea textArea)
        {
            if (textArea == null)
            {
                throw new ArgumentNullException("textArea");
            }
            Rect textViewBounds  = textArea.TextView.GetBounds();
            Rect characterBounds = textArea.TextView.GetCharacterBounds(textArea.Caret.Position, source);

            if (source != null)
            {
                Matrix transformToDevice = source.CompositionTarget.TransformToDevice;
                textViewBounds.Transform(transformToDevice);
                characterBounds.Transform(transformToDevice);
            }
            CompositionForm form = new CompositionForm();

            form.dwStyle        = 0x0020;
            form.ptCurrentPos.x = (int)Math.Max(characterBounds.Left, textViewBounds.Left);
            form.ptCurrentPos.y = (int)Math.Max(characterBounds.Top, textViewBounds.Top);
            form.rcArea.left    = (int)textViewBounds.Left;
            form.rcArea.top     = (int)textViewBounds.Top;
            form.rcArea.right   = (int)textViewBounds.Right;
            form.rcArea.bottom  = (int)textViewBounds.Bottom;
            return(ImmSetCompositionWindow(hIMC, ref form));
        }
示例#2
0
        public static bool SetCompositionWindow(HwndSource source, IntPtr hIMC, TextArea textArea)
        {
            if (textArea == null)
            {
                throw new ArgumentNullException("textArea");
            }
            Rect            textViewBounds  = textArea.TextView.GetBounds(source);
            Rect            characterBounds = textArea.TextView.GetCharacterBounds(textArea.Caret.Position, source);
            CompositionForm form            = new CompositionForm();

            /* Az Add Start IME変換窓の位置 */
            //form.dwStyle = 0x0020;
            form.dwStyle = 0x0001;
            // CFS_DEFAULT            0x0000 コンポジションウィンドウをクライアントエリアの外側に描画する
            // CFS_RECT               0x0001 コンポジションウィンドウをクライアントエリアの指定された範囲内に描画する(rcAreaを使用する)
            // CFS_POINT              0x0002 コンポジションウィンドウをクライアントエリアの指定された位置に描画する(ptCurrentPosを使用する)
            // CFS_FORCE_POSITION     0x0020 コンポジションウィンドウをクライアントエリアの指定された位置に描画する(ptCurrentPosを使用する)
            // CFS_CANDIDATEPOS       0x0040
            // CFS_EXCLUDE            0x0080

            /* Az Add End  */
            form.ptCurrentPos.x = (int)Math.Max(characterBounds.Left, textViewBounds.Left);
            form.ptCurrentPos.y = (int)Math.Max(characterBounds.Top, textViewBounds.Top);
            form.rcArea.left    = (int)textViewBounds.Left;
            form.rcArea.top     = (int)textViewBounds.Top;
            form.rcArea.right   = (int)textViewBounds.Right;
            form.rcArea.bottom  = (int)textViewBounds.Bottom;
            return(ImmSetCompositionWindow(hIMC, ref form));
        }
示例#3
0
 public static void SetImmPos(int hWnd, int x, int y)
 {
     int hImc = ImmGetContext(hWnd);
     if (hImc != 0)
     {
         var frm = new CompositionForm();
         frm.CurrentPos.x = x;
         frm.CurrentPos.y = y;
         frm.Style = 2;
         ImmSetCompositionWindow(hImc, ref frm);
         ImmReleaseContext(hWnd, hImc);
     }
 }
示例#4
0
        /// <summary>
        /// 为指定的窗口设置输入法的位置
        /// </summary>
        /// <param name="x">输入法位置的X坐标</param>
        /// <param name="y">输入法位置的Y坐标</param>
        public void SetImmPos(int x, int y)
        {
            bool bolReturn = false;
            int  iError    = 0;
            int  hImc      = ImmGetContext(myControl.Handle);

            if (hImc != 0)
            {
                CompositionForm frm2 = new CompositionForm();
                frm2.CurrentPos.x = x;
                frm2.CurrentPos.y = y;
                frm2.Style        = (int)CandidateFormStyle.CFS_POINT;
                bolReturn         = ImmSetCompositionWindow(hImc, ref frm2);
                iError            = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                ImmReleaseContext(myControl.Handle, hImc);
            }
        }        // void SetImmPos
示例#5
0
        /// <summary>
        /// 为指定的窗口设置输入法的位置
        /// </summary>
        /// <param name="hWnd">窗体句柄</param>
        /// <param name="x">输入法位置的X坐标</param>
        /// <param name="y">输入法位置的Y坐标</param>
        public static void SetImmPos(int hWnd, int x, int y)
        {
            bool bolReturn = false;
            //uint iError = 0;
            int hImc = ImmGetContext(hWnd);

            if (hImc != 0)
            {
                CompositionForm frm2 = new CompositionForm();
                frm2.CurrentPos.X = x;
                frm2.CurrentPos.Y = y;
                frm2.Style        = (int)CandidateFormStyle.CFS_POINT;
                bolReturn         = ImmSetCompositionWindow(hImc, ref frm2);
                //iError = Kernel32.GetLastError();
                ImmReleaseContext(hWnd, hImc);
            }
        } // void SetImmPos
示例#6
0
 static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref CompositionForm form);
示例#7
0
 public static bool SetCompositionWindow(HwndSource source, IntPtr hIMC, TextArea textArea)
 {
     if (textArea == null)
         throw new ArgumentNullException("textArea");
     Rect textViewBounds = textArea.TextView.GetBounds(source);
     Rect characterBounds = textArea.TextView.GetCharacterBounds(textArea.Caret.Position, source);
     CompositionForm form = new CompositionForm();
     form.dwStyle = 0x0020;
     form.ptCurrentPos.x = (int)Math.Max(characterBounds.Left, textViewBounds.Left);
     form.ptCurrentPos.y = (int)Math.Max(characterBounds.Top, textViewBounds.Top);
     form.rcArea.left = (int)textViewBounds.Left;
     form.rcArea.top = (int)textViewBounds.Top;
     form.rcArea.right = (int)textViewBounds.Right;
     form.rcArea.bottom = (int)textViewBounds.Bottom;
     return ImmSetCompositionWindow(hIMC, ref form);
 }
 static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref CompositionForm form);
示例#9
0
 internal static extern bool ImmGetCompositionWindow(IntPtr hIMC, out CompositionForm form);
示例#10
0
 private static extern bool ImmSetCompositionWindow(int hImc, ref CompositionForm frm);
示例#11
0
 public static extern bool ImmSetCompositionWindow(int hImc, ref CompositionForm frm);