コード例 #1
0
ファイル: MgRichTextBox.cs プロジェクト: rinavin/RCJS
 /// <summary> return composition string, which is got from IME
 /// and stored in StringBuilder (JPN: ZIMERead function)
 /// </summary>
 public String GetCompositionString()
 {
     if (ImeReadStrBuilder == null)
     {
         return(null);
     }
     return(ImeReadStrBuilder.ToString());
 }
コード例 #2
0
ファイル: MgRichTextBox.cs プロジェクト: rinavin/RCJS
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == NativeWindowCommon.WM_IME_COMPOSITION)
            {
                switch (CultureInfo.CurrentCulture.LCID)
                {
                case 1041: // Japanese (JPN: ZIMERead function)
                    if (((int)m.LParam & NativeWindowCommon.GCS_RESULTREADSTR) > 0)
                    {
                        int hIMC = NativeWindowCommon.ImmGetContext(this.Handle);

                        try
                        {
                            int size = NativeWindowCommon.ImmGetCompositionString(hIMC, NativeWindowCommon.GCS_RESULTREADSTR, null, 0);

                            StringBuilder buffer = new StringBuilder(size);
                            NativeWindowCommon.ImmGetCompositionString(hIMC, NativeWindowCommon.GCS_RESULTREADSTR, buffer, (uint)size);
                            string str = buffer.ToString().Substring(0, size / 2);
                            ImeReadStrBuilder.Append(str);
                        }
                        finally
                        {
                            NativeWindowCommon.ImmReleaseContext(this.Handle, hIMC);
                        }
                    }
                    break;

                case 1042: // Korean
                    if (KoreanInterimSel < 0)
                    {
                        KoreanInterimSel = NativeWindowCommon.SendMessage(this.Handle, NativeWindowCommon.EM_GETSEL, 0, 0);
                    }
                    break;
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_IME_ENDCOMPOSITION)
            {
                if (CultureInfo.CurrentCulture.LCID == 1042)
                {
                    KoreanInterimSel = -1;
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_PAINT)
            {
                if (isTransparent)
                {
                    NativeWindowCommon.SendMessage(this.Handle, NativeWindowCommon.WM_NCPAINT, 0, 0);
                }

                if (ControlStyle == ControlStyle.ThreeD)
                {
                    base.WndProc(ref m);
                    using (Graphics g = Graphics.FromHwnd(this.Handle))
                    {
                        BorderRenderer.PaintBorder(g, ClientRectangle, ForeColor, ControlStyle.ThreeD, false);
                        return;
                    }
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_NCCALCSIZE)
            {
                if (BorderStyle == BorderStyle.FixedSingle)
                {
                    RecalcNonClientArea(ref m);
                }
            }
            else if (m.Msg == NativeWindowCommon.WM_NCPAINT)
            {
                if (BorderStyle == BorderStyle.FixedSingle)
                {
                    WMNCPaint(ref m);
                }
            }
            base.WndProc(ref m);
        }