예제 #1
0
        private void IMEChangeCandidate()
        {
            uint length = IMM.ImmGetCandidateList(_context, 0, IntPtr.Zero, 0);

            if (length > 0)
            {
                IntPtr pointer = Marshal.AllocHGlobal((int)length);
                length = IMM.ImmGetCandidateList(_context, 0, pointer, length);
                IMM.CandidateList cList =
                    (IMM.CandidateList)Marshal.PtrToStructure(pointer, typeof(IMM.CandidateList));
                CandidatesSelection = cList.dwSelection;
                CandidatesPageStart = cList.dwPageStart;
                CandidatesPageSize  = cList.dwPageSize;
                if (cList.dwCount > 1)
                {
                    Candidates = new string[cList.dwCount];
                    for (int i = 0; i < cList.dwCount; i++)
                    {
                        int sOffset = Marshal.ReadInt32(pointer, 24 + 4 * i);
                        Candidates[i] = Marshal.PtrToStringUni((IntPtr)(pointer.ToInt32() + sOffset));
                    }
                    if (onCandidatesReceived != null)
                    {
                        onCandidatesReceived(this, EventArgs.Empty);
                    }
                }
                else
                {
                    IMECloseCandidate();
                }
                Marshal.FreeHGlobal(pointer);
            }
        }
예제 #2
0
 private void IMESetContext(ref Message msg)
 {
     if (msg.WParam.ToInt32() == 1)
     {
         IntPtr ptr = IMM.ImmGetContext(Handle);
         if (_context == IntPtr.Zero)
         {
             _context = ptr;
         }
         else if (ptr == IntPtr.Zero && IsEnabled)
         {
             enableIME();
         }
         _compcurpos.IMEHandle     = _context;
         _compstr.IMEHandle        = _context;
         _compclause.IMEHandle     = _context;
         _compattr.IMEHandle       = _context;
         _compread.IMEHandle       = _context;
         _compreadclause.IMEHandle = _context;
         _compreadattr.IMEHandle   = _context;
         _resstr.IMEHandle         = _context;
         _resclause.IMEHandle      = _context;
         _resread.IMEHandle        = _context;
         _resreadclause.IMEHandle  = _context;
         if (!_showIMEWin)
         {
             msg.LParam = (IntPtr)0;
         }
     }
 }
        internal override void Update()
        {
            Length = IMM.ImmGetCompositionString(IMEHandle, Flag, IntPtr.Zero, 0);
            IntPtr pointer = Marshal.AllocHGlobal(Length);

            try {
                IMM.ImmGetCompositionString(IMEHandle, Flag, pointer, Length);
                _values = new byte[Length];
                Marshal.Copy(pointer, _values, 0, Length);
            } finally {
                Marshal.FreeHGlobal(pointer);
            }
        }
            public bool PreFilterMessage(ref Message m)
            {
                switch (m.Msg)
                {
                case IMM.KeyDown:
                    IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(m));
                    Marshal.StructureToPtr(m, intPtr, true);
                    IMM.TranslateMessage(intPtr);
                    return(false);

                case 0x020A:
                    // Mouse wheel is not correct if the IME helper is used, thus it is needed to grab the value here.
                    MouseWheel += (int)(short)((uint)(int)m.WParam >> 16);
                    return(false);
                }
                return(false);
            }
 internal override void Update()
 {
     Value = IMM.ImmGetCompositionString(IMEHandle, Flag, IntPtr.Zero, 0);
 }
예제 #6
0
 /// <summary>
 /// Disable the IME
 /// </summary>
 public void disableIME()
 {
     IsEnabled = false;
     IMM.ImmAssociateContext(Handle, IntPtr.Zero);
 }
예제 #7
0
 /// <summary>
 /// Enable the IME
 /// </summary>
 public void enableIME()
 {
     IsEnabled = true;
     IMM.ImmAssociateContext(Handle, _context);
 }