示例#1
0
        protected override void OnHandleDestroyed(EventArgs e)
        {
            GDI.DeleteDC(FMemDC);
            User.ReleaseDC(this.Handle, FDC);

            Imm.ImmReleaseContext(this.Handle, FhImc);
            base.OnHandleDestroyed(e);
        }
示例#2
0
        protected override void CreateHandle()
        {
            base.CreateHandle();
            if (!DesignMode)
            {
                FCaret = new HCCaret(this.Handle);
            }

            if (FDC == IntPtr.Zero)
            {
                FDC = User.GetDC(this.Handle);
                //FMemDC = (IntPtr)GDI.CreateCompatibleDC(FDC);
            }

            FhImc = Imm.ImmGetContext(this.Handle);
        }
示例#3
0
        private void UpdateImmPosition()
        {
            // 全局 FhImc
            LOGFONT vLogFont = new LOGFONT();

            Imm.ImmGetCompositionFont(FhImc, ref vLogFont);
            vLogFont.lfHeight = 22;
            Imm.ImmSetCompositionFont(FhImc, ref vLogFont);
            // 告诉输入法当前光标位置信息
            COMPOSITIONFORM vCF = new COMPOSITIONFORM();

            vCF.ptCurrentPos = new POINT(FCaret.X, FCaret.Y + 5);  // 输入法弹出窗体位置
            vCF.dwStyle      = 1;

            Rectangle vr = this.ClientRectangle;

            vCF.rcArea = new RECT(vr.Left, vr.Top, vr.Right, vr.Bottom);
            Imm.ImmSetCompositionWindow(FhImc, ref vCF);
        }
示例#4
0
        protected override void WndProc(ref Message Message)
        {
            switch (Message.Msg)
            {
            case User.WM_GETDLGCODE:
                Message.Result = (IntPtr)(User.DLGC_WANTTAB | User.DLGC_WANTARROWS);
                return;

            case User.WM_ERASEBKGND:
                Message.Result = (IntPtr)1;
                return;

            case User.WM_SETFOCUS:
            case User.WM_NCPAINT:
                base.WndProc(ref Message);
                FStyle.UpdateInfoReCaret(false);
                FStyle.UpdateInfoRePaint();
                CheckUpdateInfo();
                return;

            case User.WM_KILLFOCUS:
                base.WndProc(ref Message);
                if (Message.WParam != Handle)
                {
                    FCaret.Hide();
                }
                return;

            case User.WM_IME_SETCONTEXT:
                if (Message.WParam.ToInt32() == 1)
                {
                    Imm.ImmAssociateContext(this.Handle, FhImc);
                }
                break;

            case User.WM_IME_COMPOSITION:
                if ((Message.LParam.ToInt32() & Imm.GCS_RESULTSTR) != 0)
                {
                    if (FhImc != IntPtr.Zero)
                    {
                        int vSize = Imm.ImmGetCompositionString(FhImc, Imm.GCS_RESULTSTR, null, 0);
                        if (vSize > 0)
                        {
                            byte[] vBuffer = new byte[vSize];
                            Imm.ImmGetCompositionString(FhImc, Imm.GCS_RESULTSTR, vBuffer, vSize);
                            string vS = System.Text.Encoding.Default.GetString(vBuffer);
                            if (vS != "")
                            {
                                FData.InsertText(vS);
                                FStyle.UpdateInfoRePaint();
                                FStyle.UpdateInfoReCaret();
                                CheckUpdateInfo();

                                return;
                            }
                        }

                        Message.Result = IntPtr.Zero;
                    }
                }
                break;

            case User.WM_LBUTTONDOWN:
            case User.WM_LBUTTONDBLCLK:
                if ((!DesignMode) && (!this.Focused))
                {
                    User.SetFocus(Handle);
                    if (!Focused)
                    {
                        return;
                    }
                }
                break;
            }

            base.WndProc(ref Message);
        }