111,111
社区成员




if (m.Msg == WM_IME_CHAR)
{
Debug.WriteLine("W:"+m.WParam.ToInt32());
StringBuilder str = new StringBuilder();
int size = ImmGetCompositionString(imeHandle, GCS_RESULTSTR, null, 0);
Debug.WriteLine("size:" + size);
size += sizeof(Char);
ImmGetCompositionString(imeHandle, GCS_RESULTSTR, str, size);
Debug.WriteLine(str.ToString().Substring(0, str.Length));
}
if (m.Msg == WM_IME_COMPOSITION) {
if ((m.LParam.ToInt32() & GCS_RESULTSTR )!= 0) {
Debug.WriteLine("W:" + m.WParam.ToInt32() + " L:" + m.LParam.ToInt32());
StringBuilder str = new StringBuilder();
//int size = ImmGetCompositionString(imeHandle, GCS_RESULTSTR, null, 0);
//Debug.WriteLine("size:" + size);
//size += sizeof(Char);
ImmGetCompositionString(imeHandle,GCS_RESULTSTR, str, 1024);
Debug.WriteLine(str.ToString().Substring(0,str.Length));
}
}
if (m.Msg == WM_IME_CHAR)
{
}
if (m.Msg == WM_IME_COMPOSITION) {
Debug.WriteLine("W:" + m.WParam.ToInt32() + " L:" + m.LParam.ToInt32());
StringBuilder str = new StringBuilder();
int size = ImmGetCompositionString(imeHandle, GCS_RESULTSTR, null, 0);
Debug.WriteLine("size:" + size);
size += sizeof(Char);
ImmGetCompositionString(imeHandle, GCS_RESULTSTR, str, size);
Debug.WriteLine(str.ToString().Substring(0,str.Length));
}
public const int WM_NCVATIVATE = 0x86;
public const int WM_NCPAINT = 0x0085;
public const int WM_NCCALCSIZE = 0x83;
public const int WM_NCHITTEST = 0X84;
public const int WM_CHAR=0x102;
public const int GCS_RESULTSTR = 0x800;
public const int WM_IME_SETCONTEXT = 0x281;
public const int WM_IME_CHAR = 0x286;
[DllImport("user32.dll")]
static extern IntPtr GetWindowDC(IntPtr handle);
[DllImport("imm32.dll")]
static extern IntPtr ImmGetContext(IntPtr handle);
[DllImport("imm32.dll")]
static extern bool ImmReleaseContext(IntPtr handle,IntPtr imc);
[DllImport("imm32.dll")]
static extern int ImmGetCompositionString(IntPtr imHandle,int dwIndex,StringBuilder buf,int len);
[DllImport("imm32.dll")]
static extern int ImmAssociateContext(IntPtr handle, IntPtr imeHandle);
protected override void WndProc(ref Message m)
{