IME window and custom text SWF.Control

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I wrote a simple control doing custom text handling. (No, I can't use a text
box).
I have a problem with it when entering international text through the IME
window.

If you test the very simple sample below:
class MyControl : Control
{
protected override OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
Console.WriteLine("{0} - {1}({2})", e.Handled, e.KeyChar,
(int)e.KeyChar);
}
}

And try to activate, say, the Japaneese IME window and enter some text,
you'll see that the text entered through the Japaneese IME goes twice in
OnKeyPress.

I tried something like
protected override bool ProcessKeyEventArgs(ref Message m)
{
if (m.Msg == (int)WindowMessage.WM_IME_CHAR)
return false;
return base.ProcessKeyEventArgs(ref m);
}

It seems to work.
But then I don't really understand what's going on....
Care to comment?


--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
Not sure comment is required -- the WM_IME_CHAR and WM_CHAR messages are
both documented an in Unicode app would be identical.

The TextBox knows to handle this case, now your simple control does, too.
:-)


--
MichKa [Microsoft]
NLS Collation/Locale/Keyboard Technical Lead
Globalization Infrastructure, Fonts, and Tools
Blog: http://blogs.msdn.com/michkap

This posting is provided "AS IS" with
no warranties, and confers no rights.
 
Back
Top